我使用soapUI工具从我的虚拟wsdl服务器获取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://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
并采取回应。但当我尝试从我的真实服务器请求时,我无法认证。在肥皂信封中,我添加了标题
<soap:Header>
<AUTHHEADER>
<USERNAME>Administrator</USERNAME>
<PASSWORD>Password</PASSWORD>
</AUTHHEADER>
</soap:Header>
但有些不对劲。登录和通过是对的,我查了一下。
UPD1
我发送这样的查询
<?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://schemas.xmlsoap.org/soap/envelope/">
<soap:AUTHHEADER>
<soap:USERNAME>Administrator</soap:USERNAME>
<soap:PASSWORD>Password</soap:PASSWORD>
</soap:AUTHHEADER>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
我有
<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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server was unable to read request. ---> Request format is invalid: Missing required soap:Body element.</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
来自真实服务器。
答案 0 :(得分:0)
尝试更改您的查询:
<?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://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:ns0="http://schemas.microsoft.com/sharepoint/soap/">
<ns0:AUTHHEADER>
<ns0:USERNAME>Administrator</ns0:USERNAME>
<ns0:PASSWORD>Password</ns0:PASSWORD>
</ns0:AUTHHEADER>
</soap:Header>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
EDIT1:修复示例以向authheader添加另一个ns。老实说:我不知道,如果在http://schemas.microsoft.com/sharepoint/soap的ns中定义了一个authheader元素,但我假装它,因为它可能对每个WSDL接口都不同。我知道,有WSSE标准,但它以不同的XML请求编码。