我要消耗由我们的合作伙伴提供的服务。我被给了小方向,但被告知安全是PasswordDigest。我查了一下,立即看到很多关于WSE的参考资料,所以我就去了。这很容易实现,我很快就拥有了一个标准的WSE用户令牌,使用PasswordDigest坐在我的消息的SOAP头中。添加HTTP标头SoapHttpClient服务
当我们开始今天我被立刻告知测试(由错误消息)事情是不正确的。事实证明,合作伙伴不会查看SOAP头,而是需要http头中的安全信息。
我已经看到了很多关于如何将自定义HTTP标头添加到代理类的文章,但我的代理从SoapHttpClientProtocol不具有标题集合添加到继承。我正在寻找一个原始的httpWebRequest,但我有一个具体的方法来访问具有一些复杂的参数来处理(除了它感觉就像去背单词)。
什么是自定义HTTP标头添加到不具有GetWebRequest方法的服务代理类的最佳方式?
参考:
Proxy类decleration:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MtomServiceSoap11", namespace="http://ws.xxxxxxx.com/")]
public partial class MtomServiceService : System.Web.Services.Protocols.SoapHttpClientProtocol {
目标方法,我需要调用:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("uploadDocumentResponse", Namespace="http://ws.edsmtom.citizensfla.com/")]
public uploadDocumentResponse uploadDocument([System.Xml.Serialization.XmlElementAttribute(Namespace="http://ws.xxxxxxx.com/")] uploadDocumentRequest uploadDocumentRequest) {
object[] results = this.Invoke("uploadDocument", new object[] {
uploadDocumentRequest});
return ((uploadDocumentResponse)(results[0]));
}
}
与服务的实际调用非常简单。通过的对象不是:
request.criteria = docCriteria;
request.document = document;
var result = service.uploadDocument(request);
谢谢。
请不要犹豫,以便标记自己的答案 – Snowbear 2013-04-19 14:12:11