我想用Perl发出SOAP请求,我想发送原始XML数据,如
$xml = "<IODATA>
<TEST>
Hello World
</TEST>
</IODATA>";
我正在使用SOAP :: Lite:
my $soap = SOAP::Lite->service('http://localhost/cms/WebService/RDCMSXMLServer.WSDL');
$soap->Execute($xml, "", "");
但是当我检查SOAP主体时,我的xml被解析了,看起来像这样:
<IODATA>
等
WSDL文件:
<?xml version='1.0' encoding='UTF-8' ?>
<definitions
name='RDCMSXMLServer'
targetNamespace='http://tempuri.org/RDCMSXMLServer/webservice/'
xmlns:wsdlns='http://tempuri.org/RDCMSXMLServer/webservice/'
xmlns:typens='http://tempuri.org/RDCMSXMLServer/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<types>
<schema
targetNamespace='http://tempuri.org/RDCMSXMLServer/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'>
<import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/>
</schema>
</types>
<message name='XmlServer.Execute'>
<part name='sParamA' type='xsd:string'/>
<part name='sErrorA' type='xsd:anyType'/>
<part name='sResultInfoA' type='xsd:anyType'/>
</message>
<message name='XmlServer.ExecuteResponse'>
<part name='Result' type='xsd:string'/>
<part name='sErrorA' type='xsd:anyType'/>
<part name='sResultInfoA' type='xsd:anyType'/>
</message>
<portType name='XmlServerSoapPort'>
<operation name='Execute' parameterOrder='sParamA sErrorA sResultInfoA'>
<input message='wsdlns:XmlServer.Execute'/>
<output message='wsdlns:XmlServer.ExecuteResponse'/>
</operation>
</portType>
<binding name='XmlServerSoapBinding' type='wsdlns:XmlServerSoapPort' >
<stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='Execute'>
<soap:operation soapAction='http://tempuri.org/RDCMSXMLServer/action/XmlServer.Execute'/>
<input>
<soap:body
use='encoded'
namespace='http://tempuri.org/RDCMSXMLServer/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='sParamA sErrorA sResultInfoA'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://tempuri.org/RDCMSXMLServer/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='Result sErrorA sResultInfoA'/>
</output>
</operation>
</binding>
<service name='RDCMSXMLServer' >
<port name='XmlServerSoapPort' binding='wsdlns:XmlServerSoapBinding' >
<soap:address location='http://10.1.102.104:80/CMS/webservice/RDCMSXMLServer.WSDL'/>
</port>
</service>
</definitions>
我该如何改变?
非常感谢你。
克里斯
答案 0 :(得分:3)
我想用Perl发出SOAP请求,我想发送原始XML 数据
我们来看看。在SOAP::Data doc中,有一部分是关于使用原始XML的。这是:
在某些情况下,您可能需要使用raw对邮件进行编码 反序列化的XML文本。使用raw实例化SOAP :: Data对象 XML,执行以下操作:
$xml_content = "<foo><bar>123</bar></foo>"; $elem = SOAP::Data->type('xml' => $xml_content);
您也可以使用代码执行此操作。它可能看起来像这样:
my $xml = <<'XML';
<IODATA>
<TEST>
Hello World
</TEST>
</IODATA>
XML
my $soap = SOAP::Lite->service('http://localhost/cms/WebService/RDCMSXMLServer.WSDL');
my $res = $soap->sayHello(SOAP::Data->type( 'xml' => $xml ));
然而,这不起作用,因为您的WSDL文件中没有定义名为sayHello
的方法!我没有尝试过你的WSDL,但你可能想再次阅读SOAP::Lite docs来自己做。
我相信它可以工作like this或类似的(未经测试!):
use SOAP::Lite;
my $soap = SOAP::Lite->service("http://localhost/cms/WebService/RDCMSXMLServer.WSDL");
my $result = $soap->Execute($sParamA, $sErrorA,$ sResultInfoA);
print $result->result();
您可能还会发现this有帮助。