ASP.NET 3.5 Web 服务中缺少 SoapHeader 值
我已经使用方法创建了自定义 SOAPHeader 和服务。当我尝试使用该服务时,我能够创建 SOAPHeader 并分配其属性。但代理(SOAPClient)缺少 HeaderValue 属性。 我的网络方法期望此标头作为参数而不是代理的属性。
客户端代理:
MyServiceSoapClient client = new MyServiceSoapClient();
AuthHeader header = new AuthHeader();
header.UserName = "test";
client.MyMethod(header, value);
我想在“客户端”中设置标头而不是作为参数发送。
I have created a custom SOAPHeader and Service with methods. While I was trying to consume the service, I was able to create the SOAPHeader and assign its property. But the proxy(SOAPClient) is missing the HeaderValue property.
My web method is expecting this Header as a parameter instead of property of the proxy.
Client Proxy:
MyServiceSoapClient client = new MyServiceSoapClient();
AuthHeader header = new AuthHeader();
header.UserName = "test";
client.MyMethod(header, value);
I want to set the header in "client" not send as parameter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 Web 服务客户端中,请确保添加 Web 引用,而不是服务引用(WCF 服务)。这将从每个调用中删除soap 标头参数,并添加您要查找的 SoapHeaderValue 属性。
In your web service client, be sure to add a Web Reference and not a Service Reference (WCF service.) This will remove the soap header parameter from each call and add the SoapHeaderValue property you're looking for.