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

发布于 2024-10-15 06:24:00 字数 1708 浏览 3 评论 0原文

我正在尝试从 C++ 应用程序访问 .net Web 服务(内置于 2008)。我正在使用 IXMLHttpRequest 访问服务。以下是代码:

 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;

但是当我在 web.config 文件中添加以下行时,我收到了一个soap异常。为什么会发生这种情况以及解决方案是什么?如何访问使用 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>

I am trying to access a .net webservice(built in vs 2008) from a c++ application. I am using IXMLHttpRequest to access the service.Following is the code for that:

 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;

But I am getting a soap exception when I add the following line in web.config file. Why is that happening and What is the solution? How can I access the service which is using WSE?

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

I am getting the following exception:

<soap:Fault>
<faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapHeaderException: Server unavailable, please try later ---> 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木森分化 2024-10-22 06:24:00

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

这不是问题吗?也许问题是修改 web.config 时 Web 服务未启动。

SoapHeaderException: Server unavailable, please try later

isn't this the problem? Perhaps the issue is the web service is not starting when ou moduify the web.config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文