使用经典ASP调用SOAP或XML-RPC

时间:2013-11-12 10:03:46

标签: php xml soap asp-classic xml-rpc

我在SOAP和XML-RPC中有这个代码,并且无法理解它。可以任何人"翻译"它到Classsic ASP?我猜测我必须使用XMLHTTP做一些请求,但无法弄清楚要传递什么以及如何传递

Examples
SOAP
$client = new SoapClient( "http://www.mailagent.ro/MailAgentService.wsdl");
try{
$response = $client->deleteSubscription( "projectcode", 18,
"user@example.com"
);
} catch ( SoapFault $e )
{
die( "Exception: " . $e->getMessage() );
}
echo "Exit code: " . $response['op_status'] . "\n";
echo "Response message: " . $response['op_message'] . "\n";

XML-RPC

require_once( "nw.genericclient.php");
$params = array(
"cod" => "projectcode",
"campaign_id" => 18,
"email" => "user@example.com"
);
$client = new NWGClient();
try{
$response = $client->deleteSubscription( $params );
} catch ( Exception $e )
{
die( "Exception: " . $e->getMessage() );
}
echo "Exit code: " . $response['op_status'] . "\n";
echo "Response message: " . $response['op_message'] . "\n";

1 个答案:

答案 0 :(得分:0)

根据您的具体需求调整此项:

<%
'set the object
set objXMLHTTP = Server.CreateObject("Msxml2.XMLHTTP.3.0") 

'URL to SOAP namespace and connection URL
strNamespace = "name_space"
strURL = "http://the.SOAP.service.url"

'function you want to call
strFunction = "function_name"

'the SOAP Request valid XML
strRequest ="<?xml version=""1.0"" encoding=""utf-8""?>" _
& "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""  xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/""" _
& "        xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" _
& "    <SOAP-ENV:Body>" _
& "        <put your valid request xml body here/>" _
& "    </SOAP-ENV:Body>" _
& "</SOAP-ENV:Envelope>"

objXMLHTTP.open "post", "" & strURL & "", False

objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)
objXMLHTTP.setRequestHeader "SOAPAction", strNamespace & "/" & strFunction

'send the request and capture the result
Call objXMLHTTP.send(strRequest)
strResult = objXMLHTTP.responseText

'display the response
response.write strResult

%GT;