现有的 Soap WebServices 正在提供一个 WSDL 文件,该文件指定一个xsd:struct
. WebService 是用 PHP 编写的。
如果我尝试在我的 Java、Maven、Spring-ws、Axis 环境中执行 Wsdl2Java 目标,它会失败说:
[INFO] [axistools:wsdl2java {execution: default}]
[INFO] about to add compile source root
[INFO] Processing wsdl: /home/foobar/workspace/com.foobar/src/main/wsdl/foobar.wsdl
Sep 17, 2012 2:29:42 AM org.apache.axis.utils.JavaUtils isAttachmentSupported
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error generating Java code from WSDL.
Embedded error: Error running Axis
Type {http://www.w3.org/2001/XMLSchema}struct is referenced but not defined.
任何想法如何解决这一问题?
WSDL 如下所示:
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://foobar.service.de/service/v2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Soap_Manager" targetNamespace="http://foobar.service.de/service/v2">
<types>
<xsd:schema targetNamespace="http://foobar.service.de/service/v2"/>
</types>
<portType name="Soap_ManagerPort">
<operation name="searchFoo">
<documentation>searchFoo</documentation>
<input message="tns:searchFooIn"/>
<output message="tns:searchFooOut"/>
</operation>
</portType>
<binding name="Soap_ManagerBinding" type="tns:Soap_ManagerPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="searchFoo">
<soap:operation soapAction="http://foobar.service.de/service/v2#searchFoo"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://foobar.service.de/service/v2"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://foobar.service.de/service/v2"/>
</output>
</operation>
</binding>
<service name="Soap_ManagerService">
<port name="Soap_ManagerPort" binding="tns:Soap_ManagerBinding">
<soap:address location="http://foobar.service.de/service/v2"/>
</port>
</service>
<message name="searchFooIn">
<part name="param" type="xsd:struct"/>
</message>
<message name="searchFooOut">
<part name="return" type="xsd:struct"/>
</message>
</definitions>
谢谢你的帮助。
编辑1:
这个参考说:
...It's xsd:struct, which means it should be treated as an array with multiple values. Most languages render xsd:struct types as hashes with a key => value notation....
但是如何使用 Apache Axis 做到这一点?
编辑2:
这是当前的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
...
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<urls>
<url>http://foobar.service.de/wsdlv2.wsdl</url>
</urls>
<packageSpace>com.foobar.wsdl</packageSpace>
<testCases>true</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>true</subPackageByFileName>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
...
</build>
...
编辑3:
一个有效的肥皂请求看起来像这样(我从文档中得到它并用soap-ui测试它):
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:emn="interface.foobar">
<soap:Header/>
<soap:Body>
<emn:searchFoobar>
<emn:searchParameter>
<emn:username>xxxx</emn:username>
<emn:password>xxxx</emn:password>
<emn:maxHitCount>1</emn:maxHitCount>
<emn:sorting>distance</emn:sorting>
<emn:searchtext>example</emn:searchtext>
</emn:searchParameter>
</emn:searchFoobar>
</soap:Body>
</soap:Envelope>