VC 访问web service 出错!服务无法处理请求 未将对象引用设置到对象的实例

lza7 2009-02-06 01:49:00
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));


//WS服务器地址
Connector->Property["EndPointURL"] = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx";

//连接
Connector->Connect();

//动作
Connector->Property ["SoapAction"] = "http://WebXml.com.cn/qqCheckOnline";

try
{
// Begin message
Connector->BeginMessage();
// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer));
// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

// Build the SOAP Message
Serializer->startEnvelope("", "", "");
Serializer->startEnvelope("soap", "http://schemas.xmlsoap.org/soap/envelope/", "utf-8");
Serializer->SoapAttribute("xsi", "","http://www.w3.org/2001/XMLSchema-instance","xmlns");
Serializer->SoapAttribute("xsd","","http://www.w3.org/2001/XMLSchema","xmlns");

Serializer->startBody("");
Serializer->startElement("qqCheckOnline","","","");
Serializer->SoapAttribute("xmlns", "http://www.WebXml.com.cn/", "", "");

Serializer->startElement(_bstr_t("qqCode"),"","","");
Serializer->writeString(_bstr_t("251833888"));
Serializer->endElement();

Serializer->endElement();

Serializer->endBody();

Serializer->endEnvelope();

// Send the message to the web service
Connector->EndMessage();
}
catch (_com_error x) //捕捉异常
{
char *s = new char[56];
strcpy(s,"99");
strcat(s,"向服务器发送信息失败");
delete []s;
}

// Read the response
Reader.CreateInstance(__uuidof(SoapReader));

// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream),"");
Reader->Envelope->text;

// Display the result
if(Reader->Fault != NULL)
{
MSXML2::IXMLDOMElementPtr s = Reader->faultstring;
printf("Fault: %s\n",(const char *)s->text);
}
else
{
printf("Answer: %s\n", (const char *)Reader->RPCResult->xml);
}


运行结果返回错误提示:服务无法处理请求 未将对象引用设置到对象的实例

应该返回"Y"或"N"才对。

请高手赐教!
...全文
528 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
JeffrySun 2009-02-08
  • 打赏
  • 举报
回复
你看看WebService接口, 是不是你少提供了什么信息给ws

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧