Read SOAP XML by ASMX web servcie function
I wrote a simple web service (ASMX) function in VB:
Public Function processMessage(ByVal Messages as XMLElement) As String
Dim strS as string
strS = Messages.outerXML
Return strS
End Function
And test by sending the following request (attempt to read two messages):
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:gps-hex-communicator">
<soap:Header/>
<soap:Body>
<processMessage xmlns="urn:gps-hex-communicator">
<Messages>
<Message>
<DeviceID>11A</DeviceID>
<MessageID>1111B</MessageID>
</Message>
<Message>
<DeviceID>22A</DeviceID>
<MessageID>2222B<MessageID>
</Message>
</Messages>
</processMessage>
</soap:Body>
</soap:Envelope>
And get the following response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<processMessageResponse xmlns="urn:gps-hex-communicator">
<processMessageResult><![CDATA[<Message xmlns="urn:gps-hex-communicator">
<DeviceID>11A</DeviceID>
<MessageID>1111B</MessageID>
</Message>]]></processMessageResult>
</processMessageResponse>
</soap:Body>
</soap:Envelope>
The problem is that it stops after reading first message and second one never shows up. How can I get it?
You have a broken tag on the second message
<MessageID>2222B<MessageID>
should probably be
<MessageID>2222B</MessageID>
Thanks everybody. I got the answer now. The XmlAnyElementAttribute helps to get everything in. So the first line of asmx function should be:
Public Function processMessage(<XmlAnyElementAttribute()> ByVal Messages as XmlElement) As String
链接地址: http://www.djcxy.com/p/18742.html
