为什么.NET XMLSerializer会自动更改我的名称空间前缀(别名)?

时间:2015-08-12 19:36:11

标签: vb.net web-services web namespaces

我正在开发一个Web服务,它需要以我们业务类型的标准定义的方式返回错误。这要求我返回一个错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
  <wsse:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
  </wsse:Security>
  </soap:Header>
  <soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Fault>
      <faultcode>s:Server</faultcode>
      <faultstring>Operator/operand type mismatch.</faultstring>
      <faultactor>urn:dealernumberID:??????</faultactor>
      <detail>
        <ErrorType xmlns="http://www.starstandards.org/webservices/2009/transport">Backend Client Fault</ErrorType>
        <ErrorDetail xmlns="http://www.starstandards.org/webservices/2009/transport">Backend client returned a fault</ErrorDetail>
      </detail>
   </soap:Fault>
  </soap:Body>
</soap:Envelope>

我创建了这样的错误,但是当服务发送它时,它看起来像这样:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
    </h:Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <s:Fault>
      <faultcode>s:Server</faultcode>
      <faultstring>Operator/operand type mismatch.</faultstring>
      <faultactor>urn:dealernumberID:??????</faultactor>
      <detail>
        <ErrorType xmlns="http://www.starstandards.org/webservices/2009/transport">Backend Client Fault</ErrorType>
        <ErrorDetail xmlns="http://www.starstandards.org/webservices/2009/transport">Backend client returned a fault</ErrorDetail>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

为什么会这样?是否有一个我可以在.NET中更改的设置,以防止它默认执行此操作?我确实理解命名空间是一个命名空间而不管前缀如何,但就像我说的那样,标准要求我们以某种方式执行它(最有可能容纳第三方将响应作为字符串读取?)

感谢您的帮助!

0 个答案:

没有答案