我在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>
问题是它在读取第一条消息后停止,第二条消息从未显示 . 我怎么才能得到它?
2 回答
谢谢大家 . 我现在得到了答案 . XmlAnyElementAttribute有助于获取所有内容 . 因此asmx函数的第一行应该是:
第二条消息上有一个损坏的标记
应该是