gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 14:24:52 25 4
gpt4 key购买 nike

我正在尝试从 C++ 应用程序访问 .net Web 服务(内置于 vs 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>

最佳答案

SoapHeaderException: Server unavailable, please try later

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

关于c++ - 使用 WSE 时无法从 C++ 客户端访问 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4826473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com