Groups | Blog | Home
all groups > dotnet web services > february 2008 >

dotnet web services : .NET WebService Method Fails to read an input parameter of string type via SOAP 1.1


Uri
2/19/2008 4:36:18 AM
Hi all,

This is my first post here so hello everybody.
I have just created a webservice that accepts a string that will be
parsed as a XML document, that is not important in this case.
The question is that if I consume the WebService with a .net proxy the
parameter is read perfectly, but when I try to build the soap message
and try to send that message to my webservice, the input parameter
that my webservice accepts is read as null. I don't understand what is
happening here,l followed the webmethod signature but it does not
work.

Please I need your help, bellow you can see the SOAP client code that
performs the call to the webservice.

' define webservices adress
dim webservice
webservice = "http://myhost/FQWebService/ProcessOrderXML.asmx"

' create xmlhttp object
set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")

' create a XML DOM object
set xmldom = server.CreateObject("Microsoft.XMLDOM")


'*************************************************************************************************
' BEGIN : XML MESSAGE

'*************************************************************************************************
soapMessage = "<?xml version=""1.0"" encoding=""UTF-8""?>"
soapMessage = soapMessage & "<soap:Envelope xmlns:xsi=""http://
www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/
2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/
envelope/"">"
soapMessage = soapMessage & "<soap:Body>"

soapMessage = soapMessage & "<PlaceOrder xmlns=""http://
myhost/"">"
soapMessage = soapMessage & "<inputXML><![CDATA[<order>" &_
" <floristId>20912</floristId>"&_
" <orderNo>96810</orderNo>"&_
" <deliveryDate>11/05/2008</
deliveryDate>"&_
" <deliveryTime>AM</
deliveryTime>"&_
" <productId>2302</productId>"&_
" <productName>Classy Lady</
productName>"&_
" <productDesc>test</
productDesc>"&_
" <message>test</message>"&_
" <price>52.0</price>"&_
" <specialRequests>ADD VASE This
is a business address</specialRequests>"&_
" <sigName>test</sigName>"&_
" <reciverName>Hope Wint</
reciverName>"&_
" <reciverAddress>Pan Caribbean
Building</reciverAddress>"&_
" <reciverAddress2>60 Knutsford
Boulevard</reciverAddress2>"&_
" <reciverCity>Kingston</
reciverCity>"&_
" <reciverZip>12343</
reciverZip>"&_
" <reciverCountry>JM</
reciverCountry>"&_
" <reciverPhone></
reciverPhone>"&_
" <reciverPhone2></
reciverPhone2>"&_
" <reciverEmail></
reciverEmail>"&_
"</order>]]></inputXML>"
soapMessage = soapMessage & "</PlaceOrder>"

soapMessage = soapMessage & "</soap:Body>"
soapMessage = soapMessage & "</soap:Envelope>"
'*************************************************************************************************
' END : XML MESSAGE

'*************************************************************************************************


'*************************************************************************************************
' open connection and send message

'*************************************************************************************************
xmlhttp.open "POST", webservice, false
xmlhttp.setRequestHeader "Man", POST & " " &
webservice & " HTTP/1.1"
xmlhttp.setRequestHeader "SOAPAction", "http://myhost/
placeOrder"
xmlhttp.setRequestHeader "Content-Type", "text/xml;
charset=utf-8"

xmlhttp.send(soapMessage)


The SOAP Signature:

SOAP 1.1
The following is a sample SOAP 1.1 request and response. The
placeholders shown need to be replaced with actual values.

POST /FQWebService/ProcessOrderXML.asmx HTTP/1.1
Host: myhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://myhost/placeOrder"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://
schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<placeOrder xmlns="http://myhost/">
<inputXML>string</inputXML>
</placeOrder>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://
schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<placeOrderResponse xmlns="http://myhost/">
<placeOrderResult>string</placeOrderResult>
</placeOrderResponse>
</soap:Body>
John Saunders [MVP]
2/19/2008 8:11:46 AM
[quoted text, click to view]

I don't know why you need to construct your SOAP message by appending
strings, but it's very error-prone. If you have to "manually" construct a
SOAP message, then you should use the DOM.

At any rate, XML is case-sensitive, and "PlaceOrder" is different from
"placeOrder".
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Uri
2/19/2008 12:00:54 PM
On 19 feb, 14:11, "John Saunders [MVP]" <john.saunders at
[quoted text, click to view]

That was my mistake, the capital letter.

AddThis Social Bookmark Button