什么:和XML:SOAP XML是什么意思?

时间:2013-12-10 20:43:41

标签: xml wcf soap

我正在从我的WCF请求中获取XML SOAP响应:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <LoginUserResponse xmlns="http://tempuri.org/">
      <LoginUserResult 
        <a:NameFirst i:nil="true" />
        <a:NameLast i:nil="true" />
        <a:Response>
          <a:Code>1</a:Code>
          <a:Message>Invalid Password</a:Message>
        </a:Response>
      </LoginUserResult>
    </LoginUserResponse>
  </s:Body>
</s:Envelope>

s:,a:和r :(这里没有显示)是什么意思?他们需要吗? 响应元素是否按字母顺序排列?

由于

1 个答案:

答案 0 :(得分:0)

s:名称空间前缀是信封根目录中定义的名称空间http://schemas.xmlsoap.org/soap/envelope/

a:命名空间前缀可以引用应该在文档中某处定义的自定义命名空间,我已经在LoginUserResult中添加了它,但它也可以在这一点之上。

i:名称空间前缀可能是指名称空间http://www.w3.org/2001/XMLSchema-instance我还添加了。

由于你没有显示r:我们无法对此发表评论。

他们需要吗?如果所有节点都是默认命名空间的一部分,则为否,否则为是(但需要定义它们)。

响应元素是否按字母顺序排序?否。

P.S。您可能也希望摆脱http://tempuri.org/命名空间。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <LoginUserResponse xmlns="http://tempuri.org/">
      <LoginUserResult xmlns:a="somenamespace" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <a:NameFirst i:nil="true" />
        <a:NameLast i:nil="true" />
        <a:Response>
          <a:Code>1</a:Code>
          <a:Message>Invalid Password</a:Message>
        </a:Response>
      </LoginUserResult>
    </LoginUserResponse>
  </s:Body>
</s:Envelope>