【发布时间】:2017-09-30 12:14:04
【问题描述】:
我在一个文件夹中有 wsdl 和相应的 xsds。我尝试使用客户端生成绑定类。但我没有在生成的存根中看到标头的绑定类作为参数。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>generate-reports-ws-code</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<bindingDirectory>${basedir}</bindingDirectory>
<bindingFiles>
<bindingFile>binding.xml</bindingFile>
</bindingFiles>
<packageName>${xsd.binding.generated.search.package.name}</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/main/resources/xsd/Search.wsdl</wsdlFile>
</wsdlFiles>
<xadditionalHeaders>true</xadditionalHeaders>
<verbose>true</verbose>
<outputDirectory>${xsd.binding.generated.directory}</outputDirectory>
</configuration>
</execution>
</executions>
然后它生成所有绑定类和以下客户端。
public interface SearchSoap {
//..
@WebMethod(operationName = "PerformContentSearch", action = "http://services.my.url./search/PerformContentSearch")
@WebResult(name = "PerformContentSearchResponse", targetNamespace = "http://types.my.url./search", partName = "parameters")
public PerformContentSearchResponse performContentSearch(
@WebParam(name = "PerformContentSearch", targetNamespace = "http://types.my.url./search", partName = "parameters")
PerformContentSearch parameters)
throws SearchExceptionSoapOut
;
}
但我期待这样的事情
@WebResult(name = "PerformContentSearchResponse", targetNamespace = "http://types.my.url./search", partName = "parameters")
@WebMethod(operationName = "PerformContentSearch", action = "http://services.my.url./search/PerformContentSearch")
public PerformContentSearchResponse performContentSearch(
@WebParam(partName = "parameters", name = "PerformContentSearch", targetNamespace = "http://types.my.url./search")
PerformContentSearch parameters,
@WebParam(partName = "requestHeader", name = "requestHeader", targetNamespace = "http://types.my.url./header", header = true)
RequestHeader requestHeader
) throws SearchExceptionSoapOut;
我在这个方法中期待 'header = true' 和另一个参数(RequestHeader)。 请注意,所有这些对象都已成功创建,但即使我将 xadditionalHeaders 设置为 true,我希望它会自动生成带有标题的方法。 我已经尝试使用 cxf-codegen-plugin ,使用 wsdl2java 目标和 -exsh arg 如下所示,但仍然没有运气。
<configuration>
<sourceRoot>${xsd.binding.generated.directory}</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/xsd/Search.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
<!-- <extraarg>-impl</extraarg> -->
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
<defaultOptions>
<noAddressBinding>true</noAddressBinding>
<bindingFiles>
<bindingFile>binding.xml</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</defaultOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
我的wsdl操作如下
<portType name="SearchSoap">
<operation name="PerformContentSearch">
<input message="svc:PerformContentSearchSoapIn"/>
<output message="svc:PerformContentSearchSoapOut"/>
<fault name="fault" message="svc:SearchExceptionSoapOut"/>
</operation>
</portType>
我只有 header.xsd,它包含在 wsdl 中。 实际上,即使我在 wsdl 中包含 header.xsd,它也没有在操作中提及,所以我指的是 here 并试图找到解决方案,要么自动生成,要么在代码中添加它。 请推荐
【问题讨论】:
标签: java maven soap wsdl2java wsimport