soap客户端:VC6.0下的SOAP客户端编程来源: 发布时间:星期六, 2009年3月28日 浏览:0次 评论:0
# #import "msxml4.dll" using MSXML2; #import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \ exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \ "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME") using MSSOAPLib30; void Add { ISoapSerializerPtr Serializer; ISoapReaderPtr Reader; ISoapConnectorPtr Connector; // Connect to the service. Connector.CreateInstance(__uuidof(HttpConnector30)); Connector->Property["EndPoURL"] = "http://localhost/05_server_sample.php"; Connector->Connect; // Begin the message. //Connector->Property["SoapAction"] = "uri:AddNumbers"; Connector->Property["SoapAction"] = "http://localhost/Reziproke"; Connector->BeginMessage; // Create the SoapSerializer object. Serializer.CreateInstance(__uuidof(SoapSerializer30)); // Connect the serializer object to the input stream of the connector object. Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); // Build the SOAP Message. Serializer->StartEnvelope("","",""); Serializer->StartBody(""); Serializer->StartElement("Reziproke","http://webservice.teserco.de/phpug/","",""); Serializer->StartElement("ReziprokeRequest","","",""); Serializer->WriteString("1000000"); Serializer->EndElement; // Serializer->StartElement("NumberTwo","","",""); // Serializer->WriteString("10"); // Serializer->EndElement; Serializer->EndElement; Serializer->EndBody; Serializer->EndEnvelope; // Send the message to the XML Web service. Connector->EndMessage; // Read the response. Reader.CreateInstance(__uuidof(SoapReader30)); // Connect the reader to the output stream of the connector object. Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), ""); // Display the result. prf("Answer: %s\n", (const char*)Reader->RpcResult->text); } { CoInitialize(NULL); Add; CoUninitialize; 0; } php服务端 05_server_sample.php: soap_defencoding = 'ISO-8859-1'; $serviceName = 'phpugSample5'; $targetNameSpace = 'http://webservice.teserco.de/phpug/'; $endPo = 'http://localhost/05_server_sample.php'; $bindingStyle = 'rpc'; $bindingTransport = 'http://schemas.xmlsoap.org/soap/http'; $server->configureWSDL( $serviceName, $targetNameSpace, $endPo, $bindingStyle, $bindingTransport); $server->wsdl->schemaTargetNamespace = 'http://webservice.teserco.de/phpug'; $methodName = 'Reziproke'; $inParam = .gif' />('income'=>'xsd:float'); $outParam = .gif' />(''=>'xsd:float'); $operationNameSpace = 'http://webservice.teserco.de/phpug/'; $soapAction = 'http://localhost/Reziproke'; $soapActionStyle = 'rpc'; $soapActionUse = 'encoded'; $documentation = 'Reziproke Doc'; $server->register( $methodName, $inParam, $outParam, $operationNameSpace, $soapAction, $soapActionStyle, $soapActionUse, $documentation); function Reziproke($value) { $faultcode = 'Server'; $faultactor = 'Actor 1'; $fault = 'Devision by Zero'; $faultdetail = 'Fehlercode 7'; ($value 0) { soap_fault($faultcode, $faultactor, $fault, $faultdetail); } { 1 / $value; } } $HTTP_RAW_POST_DATA = is($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA);?> 0
相关文章读者评论发表评论 |
|