2012-04-11 60 views
4

场景:如何修改SOAP :: Lite中的命名空间生成?

  • 客户是使用SOAP::Lite Perl脚本。
  • 服务器是使用Spring和CXF的基于Java的应用程序。

我的客户是基于WSDL产生以下SOAP请求:

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <createFolder xmlns="http://xyz.com/"> 
      <parentId xsi:type="xsd:string">1</parentId> 
      <folderName xsi:type="xsd:string">Test</folderName> 
     </createFolder> 
    </soap:Body> 
</soap:Envelope> 

这个请求将无法针对CXF。几次调查后,我发现了以下手动生产要求将工作:

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xyz="http://xyz.com/"> 
    <soap:Body> 
     <xyz:createFolder> 
      <parentId xsi:type="xsd:string">1</parentId> 
      <folderName xsi:type="xsd:string">Test</folderName> 
     </xyz:createFolder> 
    </soap:Body> 
</soap:Envelope> 

的区别是元素createFolder命名空间的定义。

我的问题是:如何配置SOAPLite来创建工作的SOAP请求?

反之亦然:如何将CXF配置为接受SOAP :: Lite请求样式?

+0

它也可能是CXF的配置问题。 – Philipp 2012-04-11 13:24:28

回答

3

查看ns。如果给出了片段的根元素类似限定名

使用下列内容:

SOAP::Lite->new->proxy('http://somewhere.com') 
    ->ns('http://xyz.com/', 'xyz')->createFolder( 
     SOAP::Data->new(name => 'parentId', value => 1, type => 'xsd:string') 
    , SOAP::Data->new(name => 'folderName', value => 'Test') 
    ); 

我有以下几点:

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xyz="http://xyz.com/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
> 
    <soap:Body> 
    <xyz:createFolder> 
     <parentId xsi:type="xsd:string">1</parentId> 
     <folderName xsi:type="xsd:string">Test</folderName> 
    </xyz:createFolder> 
    </soap:Body> 
</soap:Envelope> 

而且我认为这是你想要的。