配置 WSDD 以匹配 AXIS 中的 WSDL

ses*_*ses 5 java axis soap web-services jax-rpc

我有 WSDL(我从外部供应商那里得到的)。有这样几行:

  <xsd:complexType name="SalesRequest">
                <xsd:all>
                    <xsd:element name="merchantid" type="xsd:int"/>
                    <xsd:element name="password" type="xsd:string"/>
                    ...
                </xsd:all>
  </xsd:complexType>

  ... 
  <message name="SalesResponse">
        <part name="request" type="tns:SalesResponse"/>
  </message>
  ..
  <portType name="InterfacePortType">
    <operation name="Sales">
        <documentation>some text</documentation>
        <input message="tns:SalesRequest"/>
        <output message="tns:SalesResponse"/>
  </operation>
Run Code Online (Sandbox Code Playgroud)

我已经基于这个 WSDL(使用 JAX-RPC)生成了 Java 类。

然后我创建了 Axis 服务(MyService 实现了 InterfacePortType)。

我准备了 XSDD 文件,将 MyService 部署到 Web 应用程序。

所以,然后我调用我的 MySerive 方法之一并在服务器端响应序列化的那一刻得到这个错误:

意外元素名称:预期 = 请求,实际 = SalesReturn

这意味着我的 XSDL 和 XSDD 并没有太多其他的东西。MyService 准备了这样的响应(但计数不通过网络发送):

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope 
...
<SalesReturn href="#id0"/></ns1:SalesResponse><multiRef xmlns:ns2=
...
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

问题是:我应该如何处理 WSDD 以便在来自服务的响应 XML 中使用“请求”而不是“SalesReturn”

我不知道这个“返回”后缀从何而来。

- 我已经做了一些步骤:

我用谷歌搜索,发现 WSDL 中应该有 'schema elementFormDefault="qualified"' 。但是我不能更改 WSDL,因为它是外部的,它是由外部提供商提供给我的。

ses*_*ses 3

我找到了解决方案,我使用axistools-maven-plugin生成 WSDD ,设置: serverSide 参数为true - 然后它生成 WSDD 文件。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
     <artifactId>axistools-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>wsdl2java-job</id>
                 <phase>generate-sources</phase>
                    <goals>
                      <goal>wsdl2java</goal>
                    </goals>
                  <configuration>
                      <sourceDirectory>
                           src/main/config/wsdl2java/myfolder 
                       </sourceDirectory>
                        <outputDirectory>
                            ${generatedSourcesDirectory} 
                        </outputDirectory>
                        <testCases>false</testCases>
                        <serverSide>true</serverSide>
                        <subPackageByFileName> false 
                        </subPackageByFileName>
                        <packageSpace> my.api 
                        </packageSpace>
                        </configuration>
                   </execution>
     </plugin>
Run Code Online (Sandbox Code Playgroud)

顺便说一句,当我启动这个插件时,它最终会出现编译异常,但是,尽管如此,它可能会生成 WSDD。

然后,如果查看生成的 WSDD,会发现有一些有趣的行是我手动创建的 WSDD 中没有的:

<operation name="sales" qname="operNS:Sales" 
xmlns:operNS="urn:Interface" 
returnQName="request" 
returnType="rtns:SalesResponse" 
xmlns:rtns="urn:Interface" soapAction="urn:Interface#Sales" >
  <parameter qname="in" type="tns:SalesRequest" xmlns:tns="urn:Interface"/>
</operation>
Run Code Online (Sandbox Code Playgroud)

这部分:returnQName="request"

它还生成“typeMapping”标签(但我使用了beanMapping)

因此,一旦我将这些更改放入我的文件中,一切就开始工作了。

实际上,最初为了生成我的初始源,我使用了另一个插件:maven-antrun-plugin

但没有生成 WSDD 的选项。