NEED HELP AND FAST

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:="http://badger.com/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    _
    <ToolboxItem(False)> _
    Public Class Service1
    Inherits System.Web.Services.WebService
    <WebMethod()> _
    Public Function AuthorizeAPI(ByVal Input1 As InformationToPass) As
    ReturnParams
    Dim rp As New ReturnParams
    Dim currentDomain As AppDomain = AppDomain.CurrentDomain
    'for regular unhandled stuff
    AddHandler currentDomain.UnhandledException, AddressOf
    MYExceptionHandler
    'for threads behind forms
    'AddHandler Application.ThreadException, AddressOf
    MYThreadHandler

    '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
    UnhandledExceptionEventArgs)
    Dim EX As Exception
    EX = e.ExceptionObject
    Console.WriteLine(EX.StackTrace)
    End Sub

    Private Sub MYThreadHandler(ByVal sender As Object, ByVal e As
    Threading.ThreadExceptionEventArgs)
    Console.WriteLine(e.Exception.StackTrace)
    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"?>

    <configuration>

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

    <system.web>
    <!--
    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" />
    <pages>
    <namespaces>
    <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" />
    </namespaces>
    </pages>
    <!--
    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"
    defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
    <webServices>
    <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
    <add name="HttpSoap"/>
    </protocols>
    </webServices>

    </system.web>
    </configuration>

    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?
    op=AuthorizeAPI"
    'Dim serviceurl As String = "http://badger.com"
    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) & "http://www.w3.org/2001/
    XMLSchema-instance" & Chr(34) & ""
    msg = msg & " xmlns:xsi=" & Chr(34) & "http://www.w3.org/2001/
    XMLSchema" & Chr(34) & ""
    msg = msg & " xmlns:soap=" & Chr(34) & "http://
    schemas.xmlsoap.org/soap/envelope" & Chr(34) & ">" & vbCrLf
    msg = msg & "<soap:Body>" & vbCrLf
    msg = msg & "<AuthorizeAPI xmlns=" & Chr(34) & "http://
    badger.com" & 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>" &
    vbCrLf
    msg = msg & "<BillStreet>Bill Street 1</BillStreet>" & vbCrLf
    msg = msg & "<BillStreet2>Bill Street 2</BillStreet2>" &
    vbCrLf
    msg = msg & "<BillStreet3>Bill Street 3</BillStreet3>" &
    vbCrLf
    msg = msg & "<BillStreet4>Bill Street 4</BillStreet4>" &
    vbCrLf
    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>" &
    vbCrLf
    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>"
    'http.Headers.
    httprq = CType(System.Net.HttpWebRequest.Create(serviceurl),
    System.Net.HttpWebRequest)
    'http.Headers("SOAPACTION")= """http://badger.com/
    AuthorizeAPI""")
    'http.Headers("Content-Type") = "text/xml"
    'Dim strm As New Stream(http.GetRequestStream)
    httprq.ContentType = "text/xml"
    httprq.ContentLength = msg.Length
    httprq.Method = "POST"
    Console.Write(msg)
    strm = httprq.GetRequestStream
    strm.Write(System.Text.Encoding.ASCII.GetBytes(msg), 0,
    msg.Length)
    strm.Close()
    'http.OpenWrite("http://badger.com/AuthorizeAPI", "POST")
    'http.open("POST", serviceurl, False)
    'http.setRequestHeader("SOAPACTION", """http://badger.com/
    AuthorizeAPI""")
    'http.setRequestHeader("Content-Type", "text/xml")
    'http.UploadDataAsync("http://badger.com/AuthorizeAPI", msg)
    'http.send(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
    StreamReader(resp.GetResponseStream)
    Console.Write(sr.ReadToEnd)

    '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
    'Console.WriteLine(">")
    ' Case XmlNodeType.Text 'Display the text in each element.
    'Console.WriteLine(XmlReader.Value)
    ' Case XmlNodeType.EndElement 'Display end of element.
    'Console.Write("</" + XmlReader.Name)
    'Console.WriteLine(">")
    'End Select
    'Loop
    ' MsgBox(msg)
    'Console.Write(msg)
    Console.ReadKey()

    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="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsi="
    http://www.w3.org/2001/XMLSchema" xmlns:soap="http://
    schemas.xmlsoap.org/soap/en
    velope">
    <soap:Body>
    <AuthorizeAPI xmlns="http://badger.com">
    <Input1>
    <SerialNumber>000000000</SerialNumber>
    <Dev_SerialNumber>0000000000000</Dev_SerialNumber>
    <SJName>Me</SJName>
    <Email></Email>
    <BillStreet>Bill Street 1</BillStreet>
    <BillStreet2>Bill Street 2</BillStreet2>
    <BillStreet3>Bill Street 3</BillStreet3>
    <BillStreet4>Bill Street 4</BillStreet4>
    <BillCity>Bill City</BillCity>
    <BillState>ZZ</BillState>
    <BillZip>99998</BillZip>
    <BillCountry>USA</BillCountry>
    <BillPhone>999-999-9999</BillPhone>
    <BillFax>998-999-9999</BillFax>
    <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>
    <ShipState>ZZ</ShipState>
    <ShipZip>99999</ShipZip>
    <ShipCountry>USA</ShipCountry>
    <ShipPhone>997-999-9999</ShipPhone>
    <ShipFax>996-999-9999</ShipFax>
    <OrderNumber>AA999999</OrderNumber>
    <AccountNumber>9999-9999-9999-9999</AccountNumber>
    <MonthExpr>99</MonthExpr>
    <YearExpr>09</YearExpr>
    <CVV2>999</CVV2>
    <TransactionAmount>0.01</TransactionAmount>
    <SalesTax>0</SalesTax>
    <CustomerCode>999999</CustomerCode>
    <PONumber>False</PONumber>
    <ShippingAmount>0</ShippingAmount>
    <SummaryCommodityCode>NOTE</SummaryCommodityCode>
    <OrderString_lvl3>OrderStringstring</OrderString_lvl3>
    </Input1>
    </AuthorizeAPI>
    </Soap:Body>
    </Soap:Envelope>

    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
    1. Advertising

  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
    message.

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

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jul 19, 2007
    #2
    1. Advertising

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:
    3
    Views:
    371
    andreaz
    Dec 13, 2005
  2. Replies:
    0
    Views:
    692
  3. Michele Simionato

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

    Michele Simionato, Aug 23, 2003, in forum: Python
    Replies:
    13
    Views:
    583
  4. Robert Brewer

    RE: School Project, Need Help Fast!

    Robert Brewer, Oct 12, 2004, in forum: Python
    Replies:
    2
    Views:
    340
    Richard Blackwood
    Oct 13, 2004
  5. Juha Nieminen
    Replies:
    22
    Views:
    1,063
    Kai-Uwe Bux
    Oct 12, 2007
Loading...

Share This Page