我用vc6.0调用webservice,结果总是返回soap:Client以下是代码
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector; // Connect to the service
HRESULT hr;
hr= CoInitialize(NULL);//初始化com环境
if(FAILED(hr))
{
MessageBox("初始化COM失败");
} hr =Connector.CreateInstance(__uuidof(HttpConnector30));
if(FAILED(hr))
{
//创建com对象出错,一般是因为没有安装com
MessageBox("创建HttpConnector FAILED");
} Connector->Property["EndPointURL"] = "http://10.246.0.38:8888/DESEncryptService.asmx";//"http://localhost/WebService1/Service1.asmx";
hr=Connector->Connect();//和服务器连接
if(FAILED(hr))
{
AfxMessageBox("连接WEBSERVICE FAILED");
} // Begin message
CString cstr="";
cstr.Format("%s",method);
AfxMessageBox(cstr);
Connector->Property["SoapAction"] = "http://cmis.sinopec.com/erp/DesEncrypt/DESEncryptString";//"http://xin.org/getIP";
Connector->BeginMessage(); Serializer.CreateInstance(__uuidof(SoapSerializer30)); // 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); // 创建SOAP消息
Serializer->StartEnvelope("Soap","","");
Serializer->StartBody("");
Serializer->StartElement("DESEncryptString","http://cmis.sinopec.com/erp/DesEncrypt/DESEncryptString","","Soap");//命名空间必须有 for(int i=0;i<argv_len;i++)
{
Serializer->StartElement(args[i],"","","Soap");
Serializer->WriteString(argv[i]);
Serializer->EndElement();
}
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope(); // Send the message to the web service
Connector->EndMessage(); // 读取响应
Reader.CreateInstance(__uuidof(SoapReader30)); // 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), ""); //cout<<(const char *)Reader->RpcResult->text);
//const char * str = (const char *)Reader->RpcResult->firstChild->text; //printf("Answer: %s\n",(const char*)Reader->RpcResult->xml);
const char* returnValue=(const char*)Reader->RpcResult->text;
MessageBox((const char*)Reader->RpcResult->text);
MessageBox((const char*)Reader->RpcResult->xml);
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector; // Connect to the service
HRESULT hr;
hr= CoInitialize(NULL);//初始化com环境
if(FAILED(hr))
{
MessageBox("初始化COM失败");
} hr =Connector.CreateInstance(__uuidof(HttpConnector30));
if(FAILED(hr))
{
//创建com对象出错,一般是因为没有安装com
MessageBox("创建HttpConnector FAILED");
} Connector->Property["EndPointURL"] = "http://10.246.0.38:8888/DESEncryptService.asmx";//"http://localhost/WebService1/Service1.asmx";
hr=Connector->Connect();//和服务器连接
if(FAILED(hr))
{
AfxMessageBox("连接WEBSERVICE FAILED");
} // Begin message
CString cstr="";
cstr.Format("%s",method);
AfxMessageBox(cstr);
Connector->Property["SoapAction"] = "http://cmis.sinopec.com/erp/DesEncrypt/DESEncryptString";//"http://xin.org/getIP";
Connector->BeginMessage(); Serializer.CreateInstance(__uuidof(SoapSerializer30)); // 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); // 创建SOAP消息
Serializer->StartEnvelope("Soap","","");
Serializer->StartBody("");
Serializer->StartElement("DESEncryptString","http://cmis.sinopec.com/erp/DesEncrypt/DESEncryptString","","Soap");//命名空间必须有 for(int i=0;i<argv_len;i++)
{
Serializer->StartElement(args[i],"","","Soap");
Serializer->WriteString(argv[i]);
Serializer->EndElement();
}
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope(); // Send the message to the web service
Connector->EndMessage(); // 读取响应
Reader.CreateInstance(__uuidof(SoapReader30)); // 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), ""); //cout<<(const char *)Reader->RpcResult->text);
//const char * str = (const char *)Reader->RpcResult->firstChild->text; //printf("Answer: %s\n",(const char*)Reader->RpcResult->xml);
const char* returnValue=(const char*)Reader->RpcResult->text;
MessageBox((const char*)Reader->RpcResult->text);
MessageBox((const char*)Reader->RpcResult->xml);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货