将凭据从C#传递给soap服务 [英] Passing credentials to soap service from C#

查看:117
本文介绍了将凭据从C#传递给soap服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

i试图从我的.net应用程序调用soap web服务并获取

错误407需要代理身份验证。

在肥皂文档模型中,他们已经写了这个凭证,但我不知道在调用服务时传递这些信息。

i我通过在visual studio 2008中添加web引用来调用serive。 />
我的代码是这个

******************************** ******

//创建输入对象

MyImportLead [] leads = new MyImportLead [1];

MyImportLead ld = new MyImportLead();

MyInput inpt = new MyInput();

inpt.ListOfMyImportLead = leads;



//创建Cleint

MyService clt = new MyService();

//呼叫服务&获取输出

MessageBox.Show(服务即将启动);

MyOutput outPut = clt.GetOutput(inpt);

MessageBox .Show(服务成功发布);

******************************* *********



******************** SOAP Envelop *** *************

Dear,
i am trying to call a soap web service from my .net application and getting
"Error 407 Proxy authentication is required."
in soap document model they have written this credential to pass but i have no idea to pass this information while calling the service.
i am calling serive by adding web reference in visual studio 2008.
My code is this
**************************************
//Creating Input objects
MyImportLead[] leads = new MyImportLead[1];
MyImportLead ld = new MyImportLead();
MyInput inpt =new MyInput();
inpt.ListOfMyImportLead = leads;

//Creating Cleint
MyService clt = new MyService();
//Calling Service & getting output
MessageBox.Show("Service is about to launch");
MyOutput outPut = clt.GetOutput(inpt);
MessageBox.Show("Srvice is launched successfully");
****************************************

********************SOAP Envelop****************

- <soapenv:Header>
  <UsernameToken xmlns="http://siebel.com/webservices">SADMIN</UsernameToken>
  <PasswordText xmlns="http://siebel.com/webservices">SADM1N13PGL</PasswordText>
  <SessionType xmlns="http://siebel.com/webservices">None</SessionType>
  </soapenv:Header>



************************* *******************************



任何人都可以帮我解决问题称这个服务通过我们的客户在肥皂信封中提供的这些凭证。

感谢


****************************************************

Can any one help me how to call this service passing these credentials which our client has given in soap envelope.
thanks

推荐答案

有一个名为'Credentials'的属性设置为uthenticate服务。

对你而言,这可能如下: -



There is a property called 'Credentials' to be set toa uthenticate the Service.
For you this might be as below :-

clt.Credentials = new
           NetworkCredential("username", "password", "domain name");





添加此行以通过要获得服务的凭证详细信息,然后调用您所需的方法。

请查看此信息并告知我它是否适合您。



否则你可以在这里通过自定义标题查找身份验证的.Net Web服务。

使用自定义SOAP标头验证.NET Web服务 [ ^ ]



希望这将是为你工作。



Add this line to pass the credential details to service and then call your required method.
Please check with this and let me know if it works for you.

Else you can look for the authenticating .Net Web Service through custom header here.
Authenticate .NET Web Service with Custom SOAP Header[^]

Hope this will be working for you.


亲爱的smruti,

i添加了这段代码,但它仍然给出了同样的错误。



Dear smruti,
i have added this code but still it gives same error.

clt.ClientCredentials.UserName.UserName = "abc";
                clt.ClientCredentials.UserName.Password = "123456";





我的app.config包含此代码。



********* ************************** *



My app.config contains this code.

***********************************

<system.net>
   <settings>
     <servicePointManager expect100Continue="false" />
   </settings>
 </system.net>

<security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
</transport></security>



********************************* **

你能检查一下是否有可能吗?

thnx


***********************************
Can u check if any thing is possible?
thnx


这篇关于将凭据从C#传递给soap服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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