vc6.0中调用webservice返回soap:server的问题

东风吹雪不留痕 2009-12-21 04:05:48
执行如下代码时,返回值为soap:server,那位高手请帮看看,50分

CString GetBibleWordsByBookTitleAndChapter(CString sTitle,int chapter)
{
HRESULT hr;
CString sr;
CString WebUrl = "http://www.webservicex.net/BibleWebservice.asmx?wsdl";
try
{
CoInitialize(NULL);
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr SoapConnector;
//创建SoapConnector类的对象
SoapConnector.CreateInstance(__uuidof(HttpConnector30));

//指定Web服务的地址
SoapConnector->Property ["EndPointURL"] =(LPSTR)(LPCTSTR)WebUrl;

//与Web服务连接
hr=SoapConnector->Connect();
if(FAILED(hr)) return "";

//指定Web服务完成的操作
SoapConnector->Property ["SoapAction"] = _T("http://www.webserviceX.NET/GetBibleWordsByBookTitleAndChapter");


//准备发送消息给Web服务
SoapConnector->BeginMessage();

// 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer30));

// 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)SoapConnector->InputStream));

// 创建SOAP消息

Serializer->StartEnvelope("soap","","");
Serializer->StartBody("");

Serializer->StartElement("GetBibleWordsByBookTitleAndChapter","http://www.webservicex.net","","soap");

Serializer->StartElement("BookTitle","","","soap");
Serializer->WriteString((_bstr_t)(LPCTSTR)sTitle);
Serializer->EndElement();

Serializer->StartElement("chapter","","","soap");

CString ch;
ch.Format("%d",chapter);

Serializer->WriteString((_bstr_t)(LPCTSTR) ch);
Serializer->EndElement();

Serializer->EndElement();

Serializer->EndBody();
Serializer->EndEnvelope();

//Serializer->SoapNamespace("soap","http://www.webservicex.net");

//消息真正地发给Web服务
hr=SoapConnector->EndMessage();
if(FAILED(hr)) return "";

// 读取响应
Reader.CreateInstance(__uuidof(SoapReader30));

// 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)SoapConnector->OutputStream), _T(""));

sr = CString((const char *)Reader->RpcResult->xml) ;
}
catch (_com_error e)
{
sr = (CString)(char*)e.Description();
}

return sr;
}
...全文
265 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
MoXiaoRab 2009-12-21
  • 打赏
  • 举报
回复
看我的博客
雪影 2009-12-21
  • 打赏
  • 举报
回复
帮顶
liumeiqinyang 2009-12-21
  • 打赏
  • 举报
回复
抓包看看有没有可用信息
ljz888666555 2009-12-21
  • 打赏
  • 举报
回复
帮顶。
wshcdr 2009-12-21
  • 打赏
  • 举报
回复
MK

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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