我想在Windows应用商店项目中使用带有SOAP身份验证标头(用户名,密码)的ASMX Web服务。当我将其作为服务引用添加时,缺少每个方法的MessageHeader部分。
我的ASMX服务需要客户端访问的每个方法的基本SOAP标头身份验证。但是VS2013中Windows存储项目生成的代理没有生成包含请求的SOAP头的方法。
浏览器中的我的ASMX方法:
POST /Service1.asmx HTTP/1.1
Host: domain.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://WebReference:9010/GetNewSystemno"
<?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>
<AuthHeader xmlns="http://WebReference:9010/">
<Username>string</Username>
<Password>string</Password>
</AuthHeader>
</soap:Header>
<soap:Body>
<GetNewSystemno xmlns="http://WebReference:9010/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<GetNewSystemnoResponse xmlns="http://WebReference:9010/">
<GetNewSystemnoResult>string</GetNewSystemnoResult>
</GetNewSystemnoResponse>
</soap:Body>
</soap:Envelope>
非常感谢有关此问题的任何帮助。