【发布时间】:2023-02-06 04:53:04
【问题描述】:
我们有一个由 API 提供商提供的 WSDL 示例,我们希望与其集成。
我在 https://spring.io/guides/gs/consuming-web-service/ 和其他一些 .wsdl 文件中尝试了提供的示例,一切看起来都不错。
在我使用 wsdl 的情况下 - 当运行命令生成类时 - 只生成了其中的一些,而不是全部。
在 SoapUI 中情况并非如此 - 那里一切都很好。
任何信息为什么会这样?
我的 pom.xml 如下
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.2</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>com.test.xxx.soapclient.generated</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
我所看到的是,只有 complex types 被创建为类——而其他的则没有。
在我的示例中,输入消息是下面的消息,并且没有为其生成任何类。
我怎样才能做到这一点?
另外这里有趣的是——soapAction 有空字符串作为参数——Java 的 API 需要 SoapAction
Java代码
public Object callWebService(String action, Object request){
return getWebServiceTemplate().marshalSendAndReceive(request,new SoapActionCallback(action));
}
实际的 WSDL 文件
<operation name="login" parameterOrder="user password">
<input message="tns:CardManagementEP_login"> </input>
<output message="tns:CardManagementEP_loginResponse"> </output>
</operation>
<message name="CardManagementEP_loginResponse">
<part name="result" type="xsd:string"> </part>
</message>
<message name="CardManagementEP_login">
<part name="user" type="xsd:string"> </part>
<part name="password" type="xsd:string"> </part>
</message>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://com.tch.cards.service"/>
</input>
<output>
<soap:body use="literal" namespace="http://com.tch.cards.service"/>
</output>
</operation>
【问题讨论】:
标签: spring-boot soap soap-client