c# - 为什么我会得到这个 XML block 的 org.xml.sax.SAXException?

标签 c# asp.net xml web-services soap

我已经匿名化了一些。希望它不会减损有用的信息。 stringARRAY 是我认为我被扔到的地方,但我不确定,所以如果我看错了地方,让我知道。

来自 WSDL

  <xsd:element name="LongishOpName">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" name="stringARRAY" type="xsd:string" />
        <xsd:element name="stringfield1" type="xsd:string" />
        <xsd:element name="stringfield2" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

实际的方法调用是这样的:

string originalValue = "some useful value";
string[] usefulName1 = new[] { originalValue };
service.response[] responses = server.LongishOpName( usefulName1, someString1, someString2 );

然后它向服务器生成这个 XML(感谢 Fiddler2):

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <LongishOpName xmlns="http://appropriate-namespace">
      <stringARRAY>114003</stringARRAY>
      <stringfield1>a string</stringfield1>
      <stringfield2>a string</stringfield2>
    </LongishOpName>
  </soap:Body>
</soap:Envelope>

我得到了这个回复

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>org.xml.sax.SAXException: Found character data inside an array element while deserializing</faultstring>
      <detail>
        <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">SERVERNAME</ns1:hostname>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

我的 soap 消息实际上是格式错误的吗? (是的,我正在使用 ASP.NET Web 引用来完成所有提升,我不是手动生成的)

我应该做些不同的事情吗?

我是否只需要回家 sleep ,明天一切都会“正常工作”?

最佳答案

所以这个问题的答案是:WSDL 与实际方法不匹配。我不知道这是怎么回事。

为了澄清起见,该方法接受一个包含三个字符串的数组,而不是一个字符串数组,然后是两个单独的字符串。所以要点是“仔细检查 WSDL 是否准确”。

关于c# - 为什么我会得到这个 XML block 的 org.xml.sax.SAXException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2815421/

相关文章:

c# - 根据条件从函数调用 JavaScript

c# - ASP .NET Core 2 Controller 操作的 AJAX 参数

c# - 如何将来自外部项目的 Controller 和 View 包含到 MVC6 中?

java - 使用 Java DOM 将新元素添加到 xml 文件

java - 在java中删除xml节点后,xml文件没有得到更新

c# - KeyDown 上的 Windows 应用商店应用 OEM key

c# - 当被告知线程不休眠时

c# - VSIX 扩展 : how to make atomic undo upon text replacement

c# - 禁用asp.net中div内的所有控件

java - Android应用程序备份和恢复?