关于webservice的客户端调试的问题

robinzo 2003-05-13 02:40:35
我负责开发一个客户端,webservice由别人开发,而且还没有做。。。我怎么调试啊。。。难道我也要做一个webservice来调试么。。。有没有别的办法能代替啊?各位有什么好办法?^_^
...全文
152 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
NeoXiong 2003-06-04
  • 打赏
  • 举报
回复
hi,我终于搞定了。我用的是soap toolkit2.0。
这是我在网上看到一篇vb的文章改了一下用vc实现了。你做的也是客户端吗?如果是只要服务端的人员告诉你需要传递的是什么内容的soap信息包,我的信息包内容在上面已经说了。我的代码如下,希望有所帮助,对了toolkit还有令一种实现方法,需调用服务端的wsdl,这个我就没去实现了,不知你会吗?

char * Gets(char *str1,char *str2) //这是我那系统里对soap服务的封装
{

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = "http://202...:8080/soap/servlet/rpcrouter";
Connector->Connect();

// 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->SoapNamespace("xsi","http://www.w3.org/1999/XMLSchema-instance");
Serializer->SoapNamespace("xsd","http://www.w3.org/1999/XMLSchema");
Serializer->startBody("http://schemas.xmlsoap.org/soap/encoding/");

char strings[300];
memset(strings,'\0',300);
sprintf(strings,"<ns1:getScore xmlns:ns1=\"urn:ClientTest\"><stuno xsi:type=\"xsd:string\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">%s</stuno><courseid xsi:type=\"xsd:string\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">%s</courseid></ns1:getScore>",str1,str2);
Serializer->writeXML(strings);
Serializer->endBody();
Serializer->endEnvelope();

// Send the message to the web service
Connector->EndMessage();

// Let us read the response
Reader.CreateInstance(__uuidof(SoapReader));

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

// Display the result
char *temp=new char[strlen((char *)Reader->RPCResult->text)+1];
strcpy(temp,(char *)Reader->RPCResult->text);

return temp;
}
以上代码实现了一个客户端。因为soap toolkit只支持一个soap 名字空间,因而需加上Serializer->SoapNamespace(..)增加名字空间。
又如果明确知道所传递的soap包信息,可以用Serializer->writeXML(..)
把soap信息全部写进去,而不需Serializer->StartElement(..)等。好吧,希望你早日解决问题。祝好运!
supershagua 2003-05-29
  • 打赏
  • 举报
回复
HI,我更惨,给我几个XML的DTD文档,就让我去连接他们WEBSERVICE的API,简直无从下手,有人能帮我么?
NeoXiong 2003-05-28
  • 打赏
  • 举报
回复
hi,你用的是soap toolkit吗?
我用的是它,但我不知道如何把如下soap信息传递到server:
soap包xinxi
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getScore xmlns:ns1="urn:ClientTest">
<caller xsi:type="xsd:string" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">9908208</caller>
</ns1:getScore>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

当我用如下方法时,服务器端检测到的soap信息与上面的不同,方法如下:
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = "someURL";
Connector->Connect();
// Begin message
// Connector->Property["SoapAction"] = "";
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->startBody("");
Serializer->startElement("getScore","urn:ClientTest","","ns1");
Serializer->startElement("caller","xsd:string","http://schemas.xmlsoap.org/soap/encoding/","");
Serializer->writeString("9908208");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();

// Send the message to the web service
Connector->EndMessage();

// Let us read the response
Reader.CreateInstance(__uuidof(SoapReader));

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

// Display the result
printf("Answer: %s\n", (const char*)Reader->RPCResult->text);
你能帮我解决吗?
先谢谢了!
robinzo 2003-05-16
  • 打赏
  • 举报
回复
^_^我昨天看了一篇关于调试的文章,使用Trace Tools 查看http消息进行调试,Ms SOAP Toolkit自己带一个这样的工具,还可以下载一些。推荐你看看《程序员》去年的合订本,里面关于Webservice调试的文章有点帮助
NeoXiong 2003-05-16
  • 打赏
  • 举报
回复
thanks
NeoXiong 2003-05-15
  • 打赏
  • 举报
回复
没办法,我正在学习webservice。好烦,唉!!
robinzo 2003-05-15
  • 打赏
  • 举报
回复
^_^是挺烦人的,不知道你现在用什么办法啊
NeoXiong 2003-05-13
  • 打赏
  • 举报
回复
唉,怎么跟我一样!
我是用vc开发了一个移动短信平台,现在还要去连什么webservice。别人只给了我一个c++的soap包,就要我连webservice了,唉!

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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