使用 Classic ASP 调用 SOAP 或 XML-RPC


Calling SOAP or XML-RPC with Classic ASP

我在SOAP和XML-RPC中有这段代码,但无法从中理解。任何人都可以将其"翻译"为类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";
根据您的

特定需求进行调整:

<%
'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

%>