使用GSOAP调用EWS时出现HTTP / 1.1 401未授权错误

时间:2012-01-30 12:45:14

标签: c++ web-services exchangewebservices gsoap

我在c ++中创建了一个用于调用EWS方法的GSOAP客户端应用程序。我的EWS是一个https URL。我只使用正确的凭据,但我收到的响应如下。

HTTP/1.1 401 Unauthorized  
Cache-Control: private  
Server: Microsoft-IIS/7.5  
X-AspNet-Version: 2.0.50727  
Set-Cookie: exchangecookie=b56b1f57339240a88983be18ce6a50ad; expires=Wed, 30-Jan-2013      10:59:16 GMT; path=/; HttpOnly  
WWW-Authenticate: Negotiate  
WWW-Authenticate: NTLM   
X-Powered-By: ASP.NET  
Date: Mon, 30 Jan 2012 10:59:16 GMT  
Connection: close  
Content-Length: 0  

下面我给出了我的代码片段。

ExchangeServiceBindingProxy *proxy =  new ExchangeServiceBindingProxy();  
proxy->soap_endpoint = "https://xxxx/EWS/exchange.asmx";  
proxy->userid = "xxxxx";  
proxy->passwd= "xxxxx";  
proxy->recv_timeout = 300;  
proxy->send_timeout = 300;  
proxy->version = ns3__ExchangeVersionType__Exchange2010;  
soap_ssl_init();  
if (soap_ssl_client_context(proxy,SOAP_SSL_NO_AUTHENTICATION, NULL, NULL, NULL,NULL,NULL)){ exit(1);}

请告诉任何人可能出现的问题。

感谢。

1 个答案:

答案 0 :(得分:0)

使用cc -DWITH_NTLM(或win上的/ DWITH_NTLM)重新编译源代码以启用gSOAP NTLM身份验证协议。