Discussion in 'ASP .Net' started by Brent White, Jul 19, 2007.

  1. Brent White

    Brent White Guest

    I have been posting all over the 'net and no one seems to know how to
    help. I have a web service that I have been trying to write to using
    SOAP and now I'm getting this cryptic Internal Server Error message
    with no information as to why. This is my web service:

    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.ComponentModel

    <System.Web.Services.WebService(Namespace:="")> _
    <ToolboxItem(False)> _
    Public Class Service1
    Inherits System.Web.Services.WebService
    <WebMethod()> _
    Public Function AuthorizeAPI(ByVal Input1 As InformationToPass) As
    Dim rp As New ReturnParams
    Dim currentDomain As AppDomain = AppDomain.CurrentDomain
    'for regular unhandled stuff
    AddHandler currentDomain.UnhandledException, AddressOf
    'for threads behind forms
    'AddHandler Application.ThreadException, AddressOf

    'Return "Hi, this page is served by Brent White's own system
    and can be looked at " & Input1.SecondParam & " times."
    'Return Input1.SerialNumber
    'Return Input1.Dev_SerialNumber
    rp.SJName = Input1.SJName
    rp.Email = Input1.Email
    'Return Input1.BillStreet
    'Return Input1.BillStreet2
    'Return Input1.BillStreet3
    'Return Input1.BillStreet4
    'Return Input1.BillCity
    'Return Input1.BillState
    'Return Input1.BillZip
    'Return Input1.BillCountry
    'Return Input1.BillPhone
    'Return Input1.BillFax
    'Return Input1.ShipName
    'Return Input1.ShipStreet
    'Return Input1.ShipStreet2
    'Return Input1.ShipStreet3
    'Return Input1.ShipStreet4
    'Return Input1.ShipCity
    'Return Input1.ShipState
    'Return Input1.ShipZip
    'Return Input1.ShipCountry
    'Return Input1.ShipPhone
    'Return Input1.ShipFax
    'Return Input1.AccountNumber
    'Return Input1.MonthExpr
    'Return Input1.YearExpr
    'Return Input1.CVV2
    'Return Input1.TransactionAmount
    'Return Input1.SalesTax
    'Return Input1.CustomerCode
    'Return Input1.PONumber
    'Return Input1.ShippingAmount
    'Return Input1.SummaryCommodityCode
    'Return Input1.OrderString_lvl3
    Return rp
    End Function
    Private Sub MYExceptionHandler(ByVal sender As Object, ByVal e As
    Dim EX As Exception
    EX = e.ExceptionObject
    End Sub

    Private Sub MYThreadHandler(ByVal sender As Object, ByVal e As
    End Sub
    End Class

    Public Class InformationToPass
    Public SerialNumber As String = "{REMOVED BY POSTER}"
    Public Dev_SerialNumber As String = "{REMOVED BY POSTER}"
    Public SJName As String
    Public Email As String
    Public BillStreet As String
    Public BillStreet2 As String
    Public BillStreet3 As String
    Public BillStreet4 As String
    Public BillCity As String
    Public BillState As String
    Public BillZip As String
    Public BillCountry As String
    Public BillPhone As String
    Public BillFax As String
    Public ShipName As String
    Public ShipStreet As String
    Public ShipStreet2 As String
    Public ShipStreet3 As String
    Public ShipStreet4 As String
    Public ShipCity As String
    Public ShipState As String
    Public ShipZip As String
    Public ShipCountry As String
    Public ShipPhone As String
    Public ShipFax As String
    Public OrderNumber As String
    Public AccountNumber As String
    Public MonthExpr As String
    Public YearExpr As String
    Public CVV2 As String
    Public TransactionAmount As String
    Public SalesTax As String
    Public CustomerCode As String
    Public PONumber As String
    Public ShippingAmount As String
    Public SummaryCommodityCode As String
    Public OrderString_lvl3 As String
    End Class

    Public Class ReturnParams
    Public SJName As String
    Public Email As String
    End Class

    This is the web.config file:
    <?xml version="1.0"?>


    <sectionGroup name="applicationSettings"
    type="System.Configuration.ApplicationSettingsGroup, System,
    Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    <section name="Testing.My.MySettings"
    type="System.Configuration.ClientSettingsSection, System,
    Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    requirePermission="false" />

    Set compilation debug="true" to insert debugging
    symbols into the compiled page. Because this
    affects performance, set this value to true only
    during development.

    Visual Basic options:
    Set strict="true" to disallow all data type conversions
    where data loss can occur.
    Set explicit="true" to force declaration of all variables.
    <customErrors mode="Off" />
    <compilation debug="true" strict="false" explicit="true" />
    <clear />
    <add namespace="System" />
    <add namespace="System.Collections" />
    <add namespace="System.Collections.Specialized" />
    <add namespace="System.Configuration" />
    <add namespace="System.Text" />
    <add namespace="System.Text.RegularExpressions" />
    <add namespace="System.Web" />
    <add namespace="System.Web.Caching" />
    <add namespace="System.Web.SessionState" />
    <add namespace="System.Web.Security" />
    <add namespace="System.Web.Profile" />
    <add namespace="System.Web.UI" />
    <add namespace="System.Web.UI.WebControls" />
    <add namespace="System.Web.UI.WebControls.WebParts" />
    <add namespace="System.Web.UI.HtmlControls" />
    The <authentication> section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    The <customErrors> section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly"
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    <add name="HttpGet"/>
    <add name="HttpPost"/>
    <add name="HttpSoap"/>


    And here is the code to call the web service to test it:

    Imports System.IO
    Imports System.Xml

    Module Module1

    Sub Main()
    Dim msg As String
    Dim strm As Stream
    'Dim strmrdr As System.IO.StreamReader
    Dim httprq As System.Net.HttpWebRequest
    'Dim bytes() As Byte
    Dim serviceurl As String = "http://localhost/Service1.asmx?
    'Dim serviceurl As String = ""
    msg = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "
    encoding=" & Chr(34) & "utf-8" & Chr(34) & "?>" & vbCrLf
    msg = msg & "<soap:Envelope "
    msg = msg & "xmlns:xsi=" & Chr(34) & "
    XMLSchema-instance" & Chr(34) & ""
    msg = msg & " xmlns:xsi=" & Chr(34) & "
    XMLSchema" & Chr(34) & ""
    msg = msg & " xmlns:soap=" & Chr(34) & "http://" & Chr(34) & ">" & vbCrLf
    msg = msg & "<soap:Body>" & vbCrLf
    msg = msg & "<AuthorizeAPI xmlns=" & Chr(34) & "http://" & Chr(34) & ">" & vbCrLf
    msg = msg & "<Input1>" & vbCrLf
    msg = msg & "<SerialNumber>000000000</SerialNumber>" & vbCrLf
    msg = msg & "<Dev_SerialNumber>0000000000000</
    Dev_SerialNumber>" & vbCrLf
    msg = msg & "<SJName>Me</SJName>" & vbCrLf
    msg = msg & "<Email></Email>" &
    msg = msg & "<BillStreet>Bill Street 1</BillStreet>" & vbCrLf
    msg = msg & "<BillStreet2>Bill Street 2</BillStreet2>" &
    msg = msg & "<BillStreet3>Bill Street 3</BillStreet3>" &
    msg = msg & "<BillStreet4>Bill Street 4</BillStreet4>" &
    msg = msg & "<BillCity>Bill City</BillCity>" & vbCrLf
    msg = msg & "<BillState>ZZ</BillState>" & vbCrLf
    msg = msg & "<BillZip>99998</BillZip>" & vbCrLf
    msg = msg & "<BillCountry>USA</BillCountry>" & vbCrLf
    msg = msg & "<BillPhone>999-999-9999</BillPhone>" & vbCrLf
    msg = msg & "<BillFax>998-999-9999</BillFax>" & vbCrLf
    msg = msg & "<ShipName>Ship to me</ShipName>" & vbCrLf
    msg = msg & "<ShipStreet>My Street 1</ShipStreet>" & vbCrLf
    msg = msg & "<ShipStreet2>My street 2</ShipStreet2>" & vbCrLf
    msg = msg & "<ShipStreet3>My street 3</ShipStreet3>" & vbCrLf
    msg = msg & "<ShipStreet4>My street 4</ShipStreet4>" & vbCrLf
    msg = msg & "<ShipCity>This is my city</ShipCity>" & vbCrLf
    msg = msg & "<ShipState>ZZ</ShipState>" & vbCrLf
    msg = msg & "<ShipZip>99999</ShipZip>" & vbCrLf
    msg = msg & "<ShipCountry>USA</ShipCountry>" & vbCrLf
    msg = msg & "<ShipPhone>997-999-9999</ShipPhone>" & vbCrLf
    msg = msg & "<ShipFax>996-999-9999</ShipFax>" & vbCrLf
    msg = msg & "<OrderNumber>AA999999</OrderNumber>" & vbCrLf
    msg = msg & "<AccountNumber>9999-9999-9999-9999</
    AccountNumber>" & vbCrLf
    msg = msg & "<MonthExpr>99</MonthExpr>" & vbCrLf
    msg = msg & "<YearExpr>09</YearExpr>" & vbCrLf
    msg = msg & "<CVV2>999</CVV2>" & vbCrLf
    msg = msg & "<TransactionAmount>0.01</TransactionAmount>" &
    msg = msg & "<SalesTax>0</SalesTax>" & vbCrLf
    msg = msg & "<CustomerCode>999999</CustomerCode>" & vbCrLf
    msg = msg & "<PONumber>False</PONumber>" & vbCrLf
    msg = msg & "<ShippingAmount>0</ShippingAmount>" & vbCrLf
    msg = msg & "<SummaryCommodityCode>NOTE</
    SummaryCommodityCode>" & vbCrLf
    msg = msg & "<OrderString_lvl3>OrderStringstring</
    OrderString_lvl3>" & vbCrLf

    msg = msg & "</Input1>" & vbCrLf
    msg = msg & "</AuthorizeAPI>" & vbCrLf
    msg = msg & "</Soap:Body>" & vbCrLf
    msg = msg & "</Soap:Envelope>"
    httprq = CType(System.Net.HttpWebRequest.Create(serviceurl),
    'http.Headers("SOAPACTION")= """
    'http.Headers("Content-Type") = "text/xml"
    'Dim strm As New Stream(http.GetRequestStream)
    httprq.ContentType = "text/xml"
    httprq.ContentLength = msg.Length
    httprq.Method = "POST"
    strm = httprq.GetRequestStream
    strm.Write(System.Text.Encoding.ASCII.GetBytes(msg), 0,
    'http.OpenWrite("", "POST")
    '"POST", serviceurl, False)
    'http.setRequestHeader("SOAPACTION", """
    'http.setRequestHeader("Content-Type", "text/xml")
    'http.UploadDataAsync("", msg)
    ' Console.Write(http.responseStream.ToString)
    'strm = http.responseStream
    Dim resp As System.Net.HttpWebResponse
    resp = CType(httprq.GetResponse, System.Net.HttpWebResponse)
    Dim sr As System.IO.StreamReader = New

    'Dim xmlreader As New XmlTextReader(strm)
    'Do While (xmlreader.Read())
    ' Select Case XmlReader.NodeType
    ' Case XmlNodeType.Element
    ' Console.Write("<" + XmlReader.Name)
    ' If XmlReader.HasAttributes Then 'If attributes exist
    ' While XmlReader.MoveToNextAttribute()
    ' 'Display attribute name and value.
    ' Console.Write(" {0}='{1}'", XmlReader.Name, XmlReader.Value)
    'End While
    'End If
    ' Case XmlNodeType.Text 'Display the text in each element.
    ' Case XmlNodeType.EndElement 'Display end of element.
    'Console.Write("</" + XmlReader.Name)
    'End Select
    ' MsgBox(msg)

    End Sub

    End Module

    When I run this I get Internal Server Error on this line:

    resp = CType(httprq.GetResponse, System.Net.HttpWebResponse)

    The Event Viewer has nothing in it for the application. This is the
    XML string that is supposedly getting to the server:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi=""
    xmlns:xsi="" xmlns:soap="http://
    <AuthorizeAPI xmlns="">
    <BillStreet>Bill Street 1</BillStreet>
    <BillStreet2>Bill Street 2</BillStreet2>
    <BillStreet3>Bill Street 3</BillStreet3>
    <BillStreet4>Bill Street 4</BillStreet4>
    <BillCity>Bill City</BillCity>
    <ShipName>Ship to me</ShipName>
    <ShipStreet>My Street 1</ShipStreet>
    <ShipStreet2>My street 2</ShipStreet2>
    <ShipStreet3>My street 3</ShipStreet3>
    <ShipStreet4>My street 4</ShipStreet4>
    <ShipCity>This is my city</ShipCity>

    What am I doing wrong? I can't even get this basic service to work
    and the service is supposed to call another service on an internet
    server elsewhere (not at liberty to say what it is). I even tried
    commenting out the part that tries to override the SERIAL NUMBER AND
    DEV_SERIAL_NUMBER with no success.
    Brent White, Jul 19, 2007
    1. Advertisements

  2. Brent White wrote:
    > What am I doing wrong?

    1. You are posting with a subject line that is totally irrelevant.
    2. You are posting with a subject line in all upper case.
    3. You post every single bit of relevant and irrelevant code that you
    have, but you don't post the most valuable information of all; the error

    Turn off "friendly http error messages" in your browser, and set
    customErrors mode="Off" in your web.config, so that you see the error

    Göran Andersson
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jul 19, 2007
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    Dec 13, 2005
  2. Replies:
  3. Michele Simionato

    Python is darn fast (was: How fast is Python)

    Michele Simionato, Aug 23, 2003, in forum: Python
  4. Robert Brewer

    RE: School Project, Need Help Fast!

    Robert Brewer, Oct 12, 2004, in forum: Python
    Richard Blackwood
    Oct 13, 2004
  5. Juha Nieminen
    Kai-Uwe Bux
    Oct 12, 2007