1

私は Axis1 で作成された動作中の Web サービスを持っており、それを Jaxws に移行しています。

作業中の WSDL ファイルから wsimport と maven を使用してクライアント クラスを作成しています。

私が抱えている問題は、ロガー内のデータを含む SOAP 応答メッセージを確認できるが、オブジェクトにこのデータが入力されていないことです。

私のwsdlは次のようになります (短くするためにサービスを 1 つだけ投稿し、一部の要素を削除したため、ResultadoProcesamiento のような欠落がある場合は無視してください):

<wsdl:definitions targetNamespace="http://ws.test" xmlns:apachesoap="http://xml.apache.org/xml-soap" 
    xmlns:impl="http://ws.test" 
    xmlns:intf="http://ws.test" 
    xmlns:tns1="http://pojo.test" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://ws.test" xmlns="http://www.w3.org/2001/XMLSchema" >
       <import namespace="http://pojo.test"/>
       <element name="validarCertificado">
        <complexType>
         <sequence>
          <element name="cert" type="xsd:string"/>
         </sequence>
        </complexType>
       </element>
       <element name="validarCertificadoResponse">
        <complexType>
         <sequence>
          <element name="validarCertificadoReturn" type="tns1:MensajeSalida"/>
         </sequence>
        </complexType>
       </element>
      </schema>
      <schema elementFormDefault="qualified" targetNamespace="http://pojo.test" xmlns="http://www.w3.org/2001/XMLSchema">
       <import namespace="http://ws.test"/>
       <complexType name="Respuesta">
        <sequence>
         <element name="excepcion" nillable="true" type="tns1:Excepcion"/>
         <element name="resultadoProcesamiento" nillable="true" type="tns1:ResultadoProcesamiento"/>
        </sequence>
       </complexType>
       <complexType name="MensajeSalida">
        <sequence>
         <element name="peticion" nillable="true" type="xsd:string"/>
         <element name="respuesta" nillable="true" type="tns1:Respuesta"/>
         <element name="versionMsg" nillable="true" type="xsd:string"/>
        </sequence>
       </complexType>
      </schema>
     </wsdl:types>

       <wsdl:message name="validarCertificadoRequest">
          <wsdl:part element="impl:validarCertificado" name="parameters"/>
       </wsdl:message>
       <wsdl:message name="validarCertificadoResponse">
          <wsdl:part element="impl:validarCertificadoResponse" name="parameters"/>
       </wsdl:message>

       <wsdl:portType name="WsTest">
          <wsdl:operation name="validarCertificado">
             <wsdl:input message="impl:validarCertificadoRequest" name="validarCertificadoRequest"/>
             <wsdl:output message="impl:validarCertificadoResponse" name="validarCertificadoResponse"/>
          </wsdl:operation>
       </wsdl:portType>

       <wsdl:binding name="WsTestSoapBinding" type="impl:WsTest">
          <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
          <wsdl:operation name="validarCertificado">
             <wsdlsoap:operation soapAction=""/>
             <wsdl:input name="validarCertificadoRequest">
                <wsdlsoap:body use="literal"/>
             </wsdl:input>
             <wsdl:output name="validarCertificadoResponse">
                <wsdlsoap:body use="literal"/>
             </wsdl:output>
          </wsdl:operation>
       </wsdl:binding>

       <wsdl:service name="WsTestService">

       </wsdl:service>

    </wsdl:definitions>

同じ名前でスキーマが異なる要素がいくつかあったため、2 つのパッケージを作成する必要がありました。

最初のパッケージ:

パッケージ情報.java

@XmlSchema(namespace = "http://ws.test", elementFormDefault = XmlNsForm.QUALIFIED)
package test.ws;

ValidarCertificadoResponse.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "validarCertificadoReturn" })
@XmlRootElement(name = "validarCertificadoResponse")
public class ValidarCertificadoResponse {

        @XmlElement(required = true)
        protected MensajeSalida validarCertificadoReturn;

2 番目のパッケージ:

パッケージ情報.java

@XmlSchema(namespace = "http://pojo.test", elementFormDefault = XmlNsForm.QUALIFIED)
package pojo.ws;

MensajeSalida.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MensajeSalida", propOrder = { "peticion", "respuesta", "versionMsg" })
public class MensajeSalida {

    @XmlElement(required = true, nillable = true)
    protected String peticion;
    @XmlElement(required = true, nillable = true)
    protected Respuesta respuesta;
    @XmlElement(required = true, nillable = true)
    protected String versionMsg;

そして、私の応答 SOAP メッセージ (いくつかのタグのみが含まれています):

<soapenv:Body>
<validarCertificadoResponse xmlns="http://ws.test">
    <validarCertificadoReturn>
      <peticion>value1</peticion>
      <respuesta>
         datas
      <respuesta/>
      <resultadoProcesamiento>
         more datas
      </resultadoProcesamiento>

jaxws-maven-plugin:2.3 によって生成されたクライアントを実行した後、ValidarCertificadoResponse には次の属性があります。

ValidarCertificadoResponse.java
   validarCertificadoReturn
       peticion = null;
       respuesta = null;
       resultadoProcesamiento = null;

あなたは何か間違っていると思いますか?WSDL に間違いがあると思いますか、それともプラグインがヘッダーを適切に作成していないのでしょうか?

ありがとう。

4

1 に答える 1

0

問題の解決策を見つけました。

応答 SOAP メッセージを確認すると、1 つのスキーマ ( http://ws.test ) しか名前が付けられていないことがわかります。したがって、2 番目のスキーマに属する他のすべての要素は、jaxws が一致するものを見つけられないため、変換できません。

自分のものではないため、Web サービスを変更することはできません。そのため、スキーマを 1 つだけ持つように wsdl を調整しました。それは最もクリーンなソリューションではないと思いますが、機能します。

これを行う方法の例を次に示します。

:

<element name="validarCertificadoResponse">
    <complexType>
      <sequence>
        <element name="validarCertificadoReturn" type="tns1:MensajeSalida"/>
      </sequence>
    </complexType>
</element>

:

<xsd:element name="validarCertificadoResponse">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="validarCertificadoReturn">
        <!-- This is the content of tns1:MensajeSalida -->
        <xsd:complexType>
         <xsd:sequence>
           <xsd:element name="peticion" type="xsd:string"/>
           <!-- This is the content of tns1:Respuesta -->
           <xsd:element name="respuesta">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="excepcion" nillable="true">
                  <!-- This is the content of tns1:Excepcion -->
                  <xsd:complexType>
                    <xsd:sequence>
                      <xsd:element name="codigoError" nillable="true" type="xsd:string"/>
                    </xsd:sequence>
                  </xsd:complexType>
                </xsd:element>
                <xsd:element name="resultadoProcesamiento" nillable="true">
                  <!-- This is the content of tns1:ResultadoProcesamiento -->
                  <xsd:complexType>
                    <xsd:sequence>
                      <xsd:element name="resultado" nillable="true" type="xsd:string"/>
                    </xsd:sequence>
                  </xsd:complexType>
                </xsd:element>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="versionMsg" type="xsd:string"/>
         </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>
于 2014-09-23T07:52:09.710 に答える