专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »C语言教程 » soap客户端:VC6.0下的SOAP客户端编程 »正文

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

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: