当WSDL没有定义时如何添加soap头? [英] How to add soap header when WSDL doesn't define?

查看:185
本文介绍了当WSDL没有定义时如何添加soap头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只使用正文内容执行WSDL,但我需要在执行期间添加标题

以进行身份​​验证和其他添加的元素。下面是标题。供您参考



由于某些原因我无法定义我的XML代码,页面不接受。





我尝试过:



我使用WSDL路径添加服务引用。 />
设置参数。

唯一缺少的是标题部分,以便使用更新请求操作验证和识别WSDL

I am executing WSDL with body content only but I need to add the header
during execution for authentication and other added elements. Below is the header. for your guidance

For some reason I cannot define my XML code, the page doesn't accept.


What I have tried:

I add a service reference using the WSDL path.
set the parameters.
the only missing is the header part in order to authenticate and recognize the WSDL using the Update Request action

推荐答案

由于您没有发布有关如何调用此Web服务或代码的任何信息。以下是一种向请求添加标题的方法。



Since you didn't post anything about how you are calling this web service or your code. Here is one way you can add headers to a request.

System.Net.WebRequest request = base.GetWebRequest(uri);
 request.Headers.Add("myheader", "myheader_value");





用于身份验证,说基本的认证。它看起来像这样:





For authentication, say basic auth. It looks something like this:

string username = "Your username";
string password = "Your password";

string base64UserPass = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));

request.Headers.Add("Authorization", "Basic " + base64UserPass);


这篇关于当WSDL没有定义时如何添加soap头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆