我正在尝试将Java Web Service客户端转换为C#。我添加了一个自定义SoapHeader类来生成必要的身份验证标头,但它们没有正确格式化。我是C#Web Services的新手,所以非常感谢任何帮助。
以下是我需要标题的格式:
<soapenv:Header>
<USER soapenv:mustUnderstand="0" xsi:type="xsd:string">xxx</USER>
<PASSWORD soapenv:mustUnderstand="0" xsi:type="xsd:string">yyy</PASSWORD>
</soapenv:Header>
以下是C#客户端生成的内容:
<soap:Header>
<wsa:Action></wsa:Action>
<wsa:MessageID>urn:uuid:ecb804bb-1104-4bfc-a8f8-c5f757d428fb</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://localhost:8081/emsapi/services/PSXAPI/r09_00_00</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-4e8c838e-230c-4fb3-99b0-74f46f3652fa">
<wsu:Created>2013-07-19T17:26:55Z</wsu:Created>
<wsu:Expires>2013-07-19T17:31:55Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
我需要将哪些内容放入SoapHeader类才能正确格式化?供您参考,这是标题类:
public class AuthHeaders : SoapHeader {
[System.Xml.Serialization.SoapElement("USER")]
[System.Xml.Serialization.SoapAttribute("USER")]
public string USER;
[System.Xml.Serialization.SoapElement("PASSWORD")]
public string PASSWORD;
}
答案 0 :(得分:0)
最终解决方案随SoapExtension类一起提供,并根据需要修改属性。