SOAP无法确定请求的根元素

时间:2015-08-13 09:58:33

标签: soap

当我尝试发布一些SOAP请求时,我收到以下错误:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
    <soap:Fault>
        <soap:Code>
            <soap:Value>soap:Receiver</soap:Value>
        </soap:Code>
        <soap:Reason>
            <soap:Text>The root element for the request could not be determined. When RoutingStyle is set to RequestElement, SoapExtensions configured via an attribute on the method cannot modify the request stream before it is read. The extension must be configured via the SoapExtensionTypes element in web.config or the request must arrive at the server as clear text.</soap:Text>
        </soap:Reason>
    </soap:Fault>
</soap:Body>

我正在使用

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:m="http://test.#######.co.uk/ws-b/>
    <soapenv:Body>
     <hs:logon>
       <hs:username>USER</m:username>
       <hs:password>pass123</m:password>
    </hs:logon>
  </soapenv:Body>
</soapenv:Envelope>

但是,我可以使用类似格式的消息获得一些工作请求。这是什么意思?

2 个答案:

答案 0 :(得分:0)

&#34; HS&#34;名称空间似乎没有被声明。此外,结束标记的名称空间与开头不同。你能尝试一下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:hs="http://test.#######.co.uk/ws-b/">
    <soapenv:Body>
     <hs:logon>
       <hs:username>USER</hs:username>
       <hs:password>pass123</hs:password>
    </hs:logon>
  </soapenv:Body>
</soapenv:Envelope>

答案 1 :(得分:0)

这就是我最终的工作:

<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
    <Body>
        <logon xmlns="http://tempuri.org/">
            <username>user</username>
            <password>password</password>

        </logon>
    </Body>
</Envelope>