Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP POST of XML/SOAP Request to ASP.NET 2.0 web service method

Status
Not open for further replies.

xcaliber2222

Programmer
Apr 10, 2008
70
0
0
US
Hello, I am trying to post xml to a webservice method that requires a complex data type. Otherwise, I could use the test harness for primitive types as is always supplied by default. I can consume the webservice method with another method, pass in parms, etc. But, I am having a problem with doing an HTTP POST to this webmethod. I'm trying to post this through a classic ASP page as so:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> Http Post Test</TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
 <%
    Dim oXml
    set oXml = Server.CreateObject ("WinHTTP.WinHttpRequest.5.1")
    Dim strData
    strData = "<?xml version=""1.0"" encoding=""UTF-8""?>  <soap:Envelope xmlns:xsi=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance""[/URL] xmlns:xsd=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema""[/URL] xmlns:soap=""[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"">[/URL]   
    <soap:Body>    
    <SetStatusTest xmlns=""[URL unfurl="true"]http://public.webservices.test.com/TestStatus"">[/URL]     <UserName>test1</UserName>     
    <Password>32345</Password>     
    <VendorID>test</VendorID>    
    <JobID>13661619</JobID>     
    <Dttm>2009-11-09T17:34:00-07:00</Dttm>     
    <AWBList>      
    <AWB>       
    <AWBNum>1111-2222</AWBNum>       
    <Description>2 taped as 1</Description>       
    <PCSList>        
    <Weight>45</Weight>        
    <Weight>20</Weight>       
    </PCSList>      
    </AWB>     
    </AWBList>     
    <BOL></BOL>    
    <Pieces>2</Pieces>     
    <Weight>65</Weight>     
    <WaitTime>0</WaitTime>     
    <CostAmount>0.00</CostAmount>     
    <CostNote></CostNote>     
    <AdtlStopFlag>N</AdtlStopFlag>     
    <SecondDrvHrs>0</SecondDrvHrs>     
    <AttemptCount>0</AttemptCount>    
    </SetStatusDrop>   
    </soap:Body>  
    </soap:Envelope>"

    Call oXml.Open("POST", "[URL unfurl="true"]http://localhost/publicwebservices/TestStatusWs.asmx")[/URL]
    Call oXml.setRequestHeader("Content-Type", "text/xml")
    Call oXml.setRequestHeader("Content-Length", Len(strData & ""))
    Call oXml.setRequestHeader("Cache-Control", "no-cache")
    Call oXml.setRequestHeader("SOAPAction", "[URL unfurl="true"]http://localhost/publicwebservices/TestStatus/SetTestStatus")[/URL]
    Call oXml.send(strData & "")

    response.write strData
 %>
 </BODY>
</HTML>

I can set a breakpoint with other webmethods and step through for the primitive data type parms, but for this one I need to send in an xml string. However, it is not hitting the method at all, so I'm thinking something might be wrong with the way the http and xml is being formed together.

I've been searching online for quite some time and cannot find a definitive answer on capturing an http post/soap request to a webmethod. I've tried Wireshark, Fiddler, and this method and I cannot see how to debug or at least check the http post operation in real time on this. So, I am hoping perhaps someone could look at the code being used to post and offer suggestions. Incidentially, the code is taken from a VB6 app which uses the exact same code, and I didn't want to rewrite this in .Net and have to use the System.Net.HttpRequest or System.Net.WebClient classes, which seemed too involved for what I want to test. In any case, any help would be so greatly appreciated.

Thanks,
Alejandro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top