在Web服务调用方面需要帮助 [英] Need help with Web Service call

查看:91
本文介绍了在Web服务调用方面需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用在Apache服务器上运行的Web服务.我在Visual Studio中添加了Web引用,但是无法对Web服务进行身份验证.
有趣的是,我可以直接使用PHP进行身份验证,而无需进行任何标头修改.

<?php

Hi Guys,

I am trying to consume a webservice that runs on a Apache server. I've added a web refrence in Visual Studio but I can't authenticate my self to the webservice.
The funny thing is that I simply can use PHP to authenticate without any header modification like.

<?php

$ client = new SoapClient('http://ws.domainname.net/soap/affiliate?wsdl');
$ client-> authenticate(12345,'c333d748df7511264ed7587d248fc7842eed77ff');

$client = new SoapClient('http://ws.domainname.net/soap/affiliate?wsdl');
$client->authenticate(12345, 'c333d748df7511264ed7587d248fc7842eed77ff');

?>

然后调用一个方法,它会给我所需的结果.如何使用以下内容:

?>

And call a methode and that give me the needed results. How ever when I use the following:

AffiliateService

myTT = AffiliateService

myTT = new AffiliateService();

 

私有 button1_Click( 对象 EventArgs e)

{

private void button1_Click(object sender, EventArgs e)

{

myTT.authenticate(

myTT.authenticate(

"12345" );

myTT.authenticateCompleted + =

"12345", "usertoken",true);

myTT.authenticateCompleted +=

(myTT_authenticateCompleted);

new authenticateCompletedEventHandler(myTT_authenticateCompleted);

 

PaymentFilter npf = PaymentFilter

PaymentFilter npf = new PaymentFilter();

npf.billDateFrom =

DateTime .现在;

npf.billDateTo =

DateTime.Now;

npf.billDateTo =

DateTime .现在;

richTextBox1.Text = myTT.getPayments(npf).ToString();

DateTime.Now;

richTextBox1.Text = myTT.getPayments(npf).ToString();

}

无效 myTT_authenticateCompleted( 发件人 AsyncCompletedEventArgs

void myTT_authenticateCompleted(object sender, AsyncCompletedEventArgs e)

{

richTextBox1.Text = myTT.getAffiliateSites().ToString();

}

richTextBox1.Text = myTT.getAffiliateSites().ToString();

}


我通过Web服务从C#表单应用程序调用得到的响应给了我未认证的信息!如果我检查SOAP标头,则其中没有身份验证标头.
为什么我可以使用简单的PHP解决方案对自己的身份进行身份验证,但是使用c#和相同的方法,我无法对自己的身份进行身份验证.

SOAP标头必须如下所示:

< soapenv:信封xmlns:xsi =" http://www.w3.org/2001/XMLSchema "xmlns:soapenv =" http://schemas.xmlsoap.org/soap/envelope/"xmlns:aff =" http://ws.webservicedomain.net/soap/affiliate >
< soapenv:Header/>
< soapenv:Body>
< aff:authenticate soapenv:encodingStyle =" http://schemas.xmlsoap.org/soap/encoding/>
.< customerID xsi:type =" xsd:positiveInteger"> 12345</customerID> ;< passphrase xsi:type =" xsd:normalizedString" token</passphrase>< sandbox xsi:type ="" xsd:boolean">< sandbox
</aff:authenticate>
</soapenv:Body>
</soapenv:Envelope>

所以我在标题中缺少以下内容当我使用c#

调用相同的方法时< aff:authenticate soapenv:encodingStyle =" http: //schemas.xmlsoap.org/soap/encoding/>
< ; customerID xsi:type =" xsd:positiveInteger"> 12345</customerID>
</sandbox</sandbox>
好的Visual Studio?任何帮助将是巨大的.谢谢您的宝贵时间.


The response that i get from the webservice with calling from c# forms app give me Not Authenticated! And if I check the SOAP headers there is no Authentication header in it.
Why am I able to use simple PHP solution to authenticate my self but with c# and the same method i cant authenticate my self.

The SOAP header must look like this:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aff="http://ws.webservicedomain.net/soap/affiliate">
   <soapenv:Header/>
   <soapenv:Body>
      <aff:authenticate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <customerID xsi:type="xsd:positiveInteger">12345</customerID>
         <passphrase xsi:type="xsd:normalizedString">token</passphrase>
         <sandbox xsi:type="xsd:boolean">?</sandbox>
      </aff:authenticate>
   </soapenv:Body>
</soapenv:Envelope>

SO I am missing the below in the header when I call the same method with c#

      <aff:authenticate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <customerID xsi:type="xsd:positiveInteger">12345</customerID>
         <passphrase xsi:type="xsd:normalizedString">token</passphrase>
         <sandbox xsi:type="xsd:boolean">?</sandbox>
      </aff:authenticate>

Is there a nice and easy way to consume a webserice with our great Visual Studio? Any help would be great. Thanks for your time.

推荐答案

您能告诉我们客户端绑定吗?身份验证可能是在传输级别而不是消息级别进行的
Can you show us the client side binding? The authentication may be taking place at the transport level not at the message level


这篇关于在Web服务调用方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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