本文介绍了访问受保护的Web服务时的HTTP状态码401(未授权)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




访问安全的第三方网络服务时,我得到的是401 HTTP状态码(未经授权)。在

浏览器中输入URL并手动输入用户名和密码时,将返回wsdl。所以用户名和密码应该是

没关系。


我正在使用这段代码:


商家myMerch = new Merchant();

myMerch.merchantIdentifier = merchantId;

myMerch.merchantName =" Merchant Name";


// WSE 2.0 Web服务接口

merchantinterfacedimeWse m_merch = new merchantinterfacedimeWse();

m_merch.Url = url;

m_merch.Credentials = new NetworkCredential(用户名,密码);


MerchantDocumentInfo [] docs = m_merch.getAllPendingDocumentInfo(myMerch," _GET_ORDERS_DATA_");


什么可以我知道吗?


谢谢,

Anton

Hi,

when accessing a secured 3rd party webservice i''m getting a 401 HTTP Statuscode (unauthorized). When entering the url in
a browser and entering the username and password manually, the wsdl is returned. So the username and password should
be ok.

I''m using this code:

Merchant myMerch = new Merchant();
myMerch.merchantIdentifier=merchantId;
myMerch.merchantName="Merchant Name";

// WSE 2.0 Webservice Interface
merchantinterfacedimeWse m_merch = new merchantinterfacedimeWse();
m_merch.Url = url;
m_merch.Credentials = new NetworkCredential(username,password);

MerchantDocumentInfo[] docs = m_merch.getAllPendingDocumentInfo(myMerch, "_GET_ORDERS_DATA_");

What can I do?

Thanks,
Anton

推荐答案





看看实际流量,例如使用Fiddler

(。


授权标题看起来好吗?即授权:基本<一些

base64编码的东西在这里>? (请注意,你也可以通过工具|文本编码/解码...来获得Fiddler解码

base64编码的东西。)


-

Arnout。

Take a look at the actual traffic, for instance using Fiddler
(www.fiddlertool.com).

Does the Authorization header look OK? I.e. "Authorization: Basic <some
base64-encoded stuff here>"? (Note that you can also have Fiddler decode
that base64-encoded stuff via "Tools | Text Encode/Decode...".)

--
Arnout.


这篇关于访问受保护的Web服务时的HTTP状态码401(未授权)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:57