通过 ASMX web servcie 函数读取 SOAP XML
我在 VB 中编写了一个简单的 Web 服务 (ASMX) 函数:
Public Function processMessage(ByVal Messages as XMLElement) As String Dim strS as string strS = Messages.outerXML Return strS End Function
并通过发送以下请求进行测试(尝试读取两条消息):
<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>
并得到以下响应:
<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>
问题是它在读取第一条消息后停止,而第二条消息永远不会显示。我怎样才能得到它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第二条消息上的标签已损坏,
可能应该是
You have a broken tag on the second message
should probably be
谢谢大家。我现在得到了答案。 XmlAnyElementAttribute 有助于获取所有内容。因此 asmx 函数的第一行应该是:
Thanks everybody. I got the answer now. The XmlAnyElementAttribute helps to get everything in. So the first line of asmx function should be: