【问题标题】:Sending an XML string inside a SOAP envelope在 SOAP 信封内发送 XML 字符串
【发布时间】:2012-08-30 02:04:11
【问题描述】:

我正在尝试调用第三方 Web 服务,该服务在肥皂信封内寻找一个 xml 字符串。但是,当我传入一个 xml 字符串时,服务器会以 400 Bad Request 响应。如果我将 xml 排除在外,那么 Web 服务会正确返回一个错误,指出它需要该参数。我已经与 web 服务的开发人员进行了交谈,他们不确定为什么会发生这种情况。

这是我发送的 SOAP 信封,有问题的节点是 <web:xmlString>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.example.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:AddWidget>
         <web:Key>6F257576-2F95-4764-8539</web:Key>
         <web:listID>62017</web:listID>
         <web:Type>S</web:Type>
         <web:format>HTML</web:format>
         <web:xmlString><xml><Emails><Emailaddress>foo@bar.com</Emailaddress><User1>263885</User1></Emails></xml></web:xmlString>
         <web:sfID>1536</web:sfID>
      </web:AddWidget>
   </soapenv:Body>

我尝试将 xml 字符串放在引号中、对其进行编码等,但没有运气。

【问题讨论】:

  • 没有看到 Web 服务的 WSDL 和 XML 架构就无法回答

标签: xml web-services soap


【解决方案1】:

我认为你需要这样做。

<web:xmlString><xml><Emails><Emailaddress>foo@bar.com</Emailaddress><User1>263885</User1></Emails></xml></web:xmlString>

不确定。您可以尝试这样做,也可以尝试不使用标签对。

<web:xmlString><Emails><Emailaddress>foo@bar.com</Emailaddress><User1>263885</User1></Emails></web:xmlString>

以上任何一个都应该有效。 否则,您需要查看 XSD(如果有)或更正确地查看 WSDL。 高温

【讨论】:

  • -1: 文档中间不能有 XML 文档。
  • 仍然没有帮助 OP,这并不奇怪,因为他提供的信息如此之少。
【解决方案2】:

我知道它很旧,但下面的一个也可能对您或已故的人有所帮助;) 迟到总比没有好。

您可以将其作为原始 xml 发送

<web:xmlString><xml><Emails><Emailaddress>foo@bar.com</Emailaddress><User1>263885</User1></Emails></xml></web:xmlString>

如果将 xmlString 声明为 XElement 数据类型

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多