结构如下:
POST /WebApp/Passportservice/Service/LoginService.asmx HTTP/1.1
Host: 192.168.0.119
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetCSLoginTickets"<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCSLoginTickets xmlns="http://tempuri.org/">
<LogonName>string</LogonName>
<Pwd>string</Pwd>
</GetCSLoginTickets>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCSLoginTicketsResponse xmlns="http://tempuri.org/">
<GetCSLoginTicketsResult>string</GetCSLoginTicketsResult>
</GetCSLoginTicketsResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /WebApp/Passportservice/Service/LoginService.asmx HTTP/1.1
Host: 192.168.0.119
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCSLoginTickets xmlns="http://tempuri.org/">
<LogonName>string</LogonName>
<Pwd>string</Pwd>
</GetCSLoginTickets>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCSLoginTicketsResponse xmlns="http://tempuri.org/">
<GetCSLoginTicketsResult>string</GetCSLoginTicketsResult>
</GetCSLoginTicketsResponse>
</soap12:Body>
</soap12:Envelope>代码如下:
CoInitialize(NULL);
//创建SoapConnector类的对象
SoapConnector.CreateInstance(__uuidof(HttpConnector)); //指定Web服务的地址
SoapConnector->Property ["EndPointURL"] = "http://oa.88574.net/WebApp/PassportService/Service/LoginService.asmx?op=GetCSLoginTickets"; //与Web服务连接
SoapConnector->Connect(); //指定Web服务完成的操作
SoapConnector->Property ["SoapAction"] = "http://tempuri.org/GetCSLoginTickets"; //准备发送消息给Web服务
SoapConnector->BeginMessage(); // 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer)); // 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)SoapConnector->InputStream));
// 创建SOAP消息
Serializer->startEnvelope("soap","http://schemas.xmlsoap.org/soap/envelope/","");
Serializer->SoapNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
Serializer->SoapNamespace("xsd","http://www.w3.org/2001/XMLSchema"); Serializer->startBody("http://schemas.xmlsoap.org/soap/envelope/"); Serializer->startElement("GetCSLoginTickets","http://tempuri.org/","",""); Serializer->startElement("LogonName","","","");
Serializer->writeString("123");
Serializer->endElement(); Serializer->startElement("Pwd","","","");
Serializer->writeString("123");
Serializer->endElement(); Serializer->endElement(); Serializer->endBody(); Serializer->endEnvelope(); //消息真正地发给Web服务
SoapConnector->EndMessage();
// 读取响应
Reader.CreateInstance(__uuidof(SoapReader)); // 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)SoapConnector->OutputStream), ""); // 显示结果
CString Str;
Str.Format("%s\n", (const char *)Reader->RPCResult->text); AfxMessageBox(Str); CoUninitialize(); 问题是:返回的内容是空的,请问大家知道原因吗?
POST /WebApp/Passportservice/Service/LoginService.asmx HTTP/1.1
Host: 192.168.0.119
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetCSLoginTickets"<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCSLoginTickets xmlns="http://tempuri.org/">
<LogonName>string</LogonName>
<Pwd>string</Pwd>
</GetCSLoginTickets>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCSLoginTicketsResponse xmlns="http://tempuri.org/">
<GetCSLoginTicketsResult>string</GetCSLoginTicketsResult>
</GetCSLoginTicketsResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /WebApp/Passportservice/Service/LoginService.asmx HTTP/1.1
Host: 192.168.0.119
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCSLoginTickets xmlns="http://tempuri.org/">
<LogonName>string</LogonName>
<Pwd>string</Pwd>
</GetCSLoginTickets>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCSLoginTicketsResponse xmlns="http://tempuri.org/">
<GetCSLoginTicketsResult>string</GetCSLoginTicketsResult>
</GetCSLoginTicketsResponse>
</soap12:Body>
</soap12:Envelope>代码如下:
CoInitialize(NULL);
//创建SoapConnector类的对象
SoapConnector.CreateInstance(__uuidof(HttpConnector)); //指定Web服务的地址
SoapConnector->Property ["EndPointURL"] = "http://oa.88574.net/WebApp/PassportService/Service/LoginService.asmx?op=GetCSLoginTickets"; //与Web服务连接
SoapConnector->Connect(); //指定Web服务完成的操作
SoapConnector->Property ["SoapAction"] = "http://tempuri.org/GetCSLoginTickets"; //准备发送消息给Web服务
SoapConnector->BeginMessage(); // 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer)); // 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)SoapConnector->InputStream));
// 创建SOAP消息
Serializer->startEnvelope("soap","http://schemas.xmlsoap.org/soap/envelope/","");
Serializer->SoapNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
Serializer->SoapNamespace("xsd","http://www.w3.org/2001/XMLSchema"); Serializer->startBody("http://schemas.xmlsoap.org/soap/envelope/"); Serializer->startElement("GetCSLoginTickets","http://tempuri.org/","",""); Serializer->startElement("LogonName","","","");
Serializer->writeString("123");
Serializer->endElement(); Serializer->startElement("Pwd","","","");
Serializer->writeString("123");
Serializer->endElement(); Serializer->endElement(); Serializer->endBody(); Serializer->endEnvelope(); //消息真正地发给Web服务
SoapConnector->EndMessage();
// 读取响应
Reader.CreateInstance(__uuidof(SoapReader)); // 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)SoapConnector->OutputStream), ""); // 显示结果
CString Str;
Str.Format("%s\n", (const char *)Reader->RPCResult->text); AfxMessageBox(Str); CoUninitialize(); 问题是:返回的内容是空的,请问大家知道原因吗?
MSXML2::IXMLDOMDocumentPtr pXMLDoc;
MSXML2::IXMLHTTPRequestPtr pXMLHTTPRequest;
2。HRESULT hr =pXMLHTTPRequest.CreateInstance(__uuidof(MSXML2::XMLHTTP30));
3。Request = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n";
Request += "<soap:Envelope xmlns:xsi=\"http:/";
Request += "/www.w3.org/2001/XMLSchema-instance\" ......
4. pXMLDoc->loadXML(_bstr_t(Request));
5. pXMLHTTPRequest->open("post","http://.....",false);
6. pXMLHTTPRequest->setRequestHeader("Content-Type", "text/xml;charset=utf-8");
pXMLHTTPRequest->setRequestHeader("SOAPAction", "Sunways.SMS.Web.Service/......");
pXMLHTTPRequest->setRequestHeader("Content-Length", (_bstr_t)strLen);
7. pXMLHTTPRequest->send(pXMLDoc->xml);
8. strResponseText = pXMLHTTPRequest->responseText;
strcpy(Result, strResponseText);