【问题标题】:Read SOAP XML by ASMX web servcie function通过 ASMX Web 服务功能读取 SOAP XML
【发布时间】:2012-02-14 11:23:06
【问题描述】:

我在 VB 中编写了一个简单的 Web 服务 (ASMX) 函数:

公共函数 processMessage(ByVal Messages as XMLElement) As String 将 strS 调暗为字符串 strS = Messages.outerXML 返回 strS 结束功能

并通过发送以下请求进行测试(尝试读取两条消息):

<soap:信封 xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:gps-hex-communicator"> <soap:标题/> <肥皂:身体> <processMessage xmlns="urn:gps-hex-communicator"> <消息> <留言> <DeviceID>11A</DeviceID> <MessageID>1111B</MessageID> </留言> <留言> <DeviceID>22A</DeviceID> <MessageID>2222B<MessageID> </留言> </消息> </processMessage> </肥皂:身体> </soap:信封>

并得到以下响应:

<soap:信封 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"> <肥皂:身体> <processMessageResponse xmlns="urn:gps-hex-communicator"> <processMessageResult><![CDATA[<Message xmlns="urn:gps-hex-communicator"> <DeviceID>11A</DeviceID> <MessageID>1111B</MessageID> </Message>]]></processMessageResult> </processMessageResponse> </肥皂:身体> </soap:信封>

问题是它在阅读第一条消息后停止,而第二条则永远不会出现。我怎样才能得到它?

【问题讨论】:

    标签: xml vb.net web-services soap asmx


    【解决方案1】:

    第二条消息的标签损坏

    <MessageID>2222B<MessageID>
    

    应该是

     <MessageID>2222B</MessageID>
    

    【讨论】:

    • 感谢指出输入错误。我现在有了解决方案。 可以用来解决问题。
    【解决方案2】:

    谢谢大家。我现在得到了答案。 XmlAnyElementAttribute 有助于获取所有内容。因此 asmx 函数的第一行应该是:

    Public Function processMessage(<XmlAnyElementAttribute()> ByVal Messages as XmlElement) As String   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-18
      • 2015-12-19
      相关资源
      最近更新 更多