VC6.0下的SOAP客户端编程

  1. #include 
  2. #import "msxml4.dll"
  3. using namespace MSXML2;
  4. #import "C:/Program Files/Common Files/MSSoap/Binaries/mssoap30.dll" /
  5. exclude("IStream""IErrorInfo""ISequentialStream""_LARGE_INTEGER", /
  6. "_ULARGE_INTEGER""tagSTATSTG""_FILETIME")
  7. using namespace MSSOAPLib30;
  8. void Add()
  9. {
  10. ISoapSerializerPtr Serializer;
  11. ISoapReaderPtr Reader;
  12. ISoapConnectorPtr Connector;
  13. // Connect to the service.
  14. Connector.CreateInstance(__uuidof(HttpConnector30));
  15. Connector->Property["EndPointURL"] = "http://localhost/05_server_sample.php";
  16. Connector->Connect();
  17. // Begin the message.
  18. //Connector->Property["SoapAction"] = "uri:AddNumbers";
  19. Connector->Property["SoapAction"] = "http://localhost/Reziproke";
  20. Connector->BeginMessage();
  21. // Create the SoapSerializer object.
  22. Serializer.CreateInstance(__uuidof(SoapSerializer30));
  23. // Connect the serializer object to the input stream of the connector object.
  24. Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
  25. // Build the SOAP Message.
  26. Serializer->StartEnvelope("","","");
  27. Serializer->StartBody("");
  28. Serializer->StartElement("Reziproke","http://webservice.teserco.de/phpug/","","");
  29. Serializer->StartElement("ReziprokeRequest","","","");
  30. Serializer->WriteString("1000000");
  31. Serializer->EndElement();
  32. // Serializer->StartElement("NumberTwo","","","");
  33. // Serializer->WriteString("10");
  34. // Serializer->EndElement();
  35. Serializer->EndElement();
  36. Serializer->EndBody();
  37. Serializer->EndEnvelope();
  38. // Send the message to the XML Web service.
  39. Connector->EndMessage();
  40. // Read the response.
  41. Reader.CreateInstance(__uuidof(SoapReader30));
  42. // Connect the reader to the output stream of the connector object.
  43. Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
  44. // Display the result.
  45. printf("Answer: %s/n", (const char*)Reader->RpcResult->text);
  46. }
  47. int main()
  48. {
  49. CoInitialize(NULL);
  50. Add();
  51. CoUninitialize();
  52. return 0;
  53. }

 php服务端

  1. 05_server_sample.php:
  2. soap_defencoding = 'ISO-8859-1';
  3. $serviceName = 'phpugSample5';
  4. $targetNameSpace = 'http://webservice.teserco.de/phpug/';
  5. $endPoint = 'http://localhost/05_server_sample.php';
  6. $bindingStyle = 'rpc';
  7. $bindingTransport = 'http://schemas.xmlsoap.org/soap/http';
  8. $server->configureWSDL(
  9. $serviceName,
  10. $targetNameSpace,
  11. $endPoint,
  12. $bindingStyle,
  13. $bindingTransport);
  14. $server->wsdl->schemaTargetNamespace = 'http://webservice.teserco.de/phpug';
  15. $methodName = 'Reziproke';
  16. $inParam = array('income'=>'xsd:float');
  17. $outParam = array('return'=>'xsd:float');
  18. $operationNameSpace = 'http://webservice.teserco.de/phpug/';
  19. $soapAction = 'http://localhost/Reziproke';
  20. $soapActionStyle = 'rpc';
  21. $soapActionUse = 'encoded';
  22. $documentation = 'Reziproke Doc';
  23. $server->register(
  24. $methodName,
  25. $inParam,
  26. $outParam,
  27. $operationNameSpace,
  28. $soapAction,
  29. $soapActionStyle,
  30. $soapActionUse,
  31. $documentation);
  32. function Reziproke($value) {
  33. $faultcode = 'Server';
  34. $faultactor = 'Actor 1';
  35. $faultstring = 'Devision by Zero';
  36. $faultdetail = 'Fehlercode 7';
  37. if ($value == 0) {
  38. return new soap_fault($faultcode$faultactor$faultstring$faultdetail);
  39. else {
  40. return 1 / $value;
  41. }
  42. }
  43. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  44. $server->service($HTTP_RAW_POST_DATA);?>

nusoap.php:下载地址http://www.2008tnjj.com/tools/soap_php_dotnet.rar

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值