使用WSE时无法从C++客户端访问Web服务

问题描述:

我试图从C++应用程序访问.net webservice(内置vs 2008)。我使用IXMLHttpRequest访问service.Following是代码为:使用WSE时无法从C++客户端访问Web服务

MSXML::IXMLHttpRequestPtr httpReq(_uuidof(MyXMLHTTPRequest)); 
_bstr_t HTTPMethod ; 
_variant_t noAsync = _variant_t((bool)false); 

HTTPMethod = _bstr_t("POST");  
httpReq->open(HTTPMethod ,"webservice address",noAsync); 
httpReq->setRequestHeader("Content-Type", "application/soap+xml"); 

CString szRequest; 
szRequest = "SOAP string"; 

VARIANT vRequest; 
vRequest.vt = VT_BSTR; 
vRequest.bstrVal = szRequest.AllocSysString(); 

httpReq->send(vRequest); 
BSTR strText; 

_bstr_t bsResponse = httpReq->responseText; 

但我得到一个SOAP异常,当我在web.config文件中添加以下行。为什么会发生这种情况,解决方案是什么?我如何访问使用WSE的服务?

<webServices> 
    <soapExtensionTypes> 
    <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxx"/> 
    </soapExtensionTypes> 
</webServices> 

我得到以下异常:

<soap:Fault> 
<faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapHeaderException: Server unavailable, please try later ---&gt; System.Threading.ThreadAbortException: Thread was being aborted. 
    at System.Threading.Thread.AbortInternal() 
at System.Threading.Thread.Abort(Object stateInfo) 
at System.Web.HttpResponse.End() 
at Microsoft.Web.Services2.WebServicesExtension.BeforeDeserializeServer(SoapServerMessage message) 
--- End of inner exception stack trace ---</faultstring><faultactor>http: //localhost:2211/WebSite/WebServices/JobLogService.asmx</faultactor></soap:Fault> 

SoapHeaderException:服务器不可用,请稍后再试

是不是这个问题?也许问题在于,当你调整web.config时,Web服务不会启动。

+0

我知道。我在问为什么会发生这种情况?解决办法是什么? – sid 2011-01-28 13:19:55