2017-03-10 14 views
0

JAX-WS WebメソッドをJavaで使用しようとしています。そして私はいくつかの設計上の問題に遭遇します。 Webサービスメソッドから生成されたXML構造体を変更しようとしています。いくつかのコード部分が以下に書かれています。私は私が欲しいものを尋ねることができるといいね。JAX-WS Webメソッドの余分なタグを防ぐ方法

以下のようなテスト用のJavaクラスを作成します。

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
"testKod" 
}) 
@XmlRootElement(name = "testService") 
public class TestService { 

    @XmlElement(required = true) 
    protected String testKod; 
    @XmlAttribute(required = true) 
    protected String uyeKod; 
    @XmlAttribute(required = true) 
    protected String islemRefNo; 
... 
} 

そして、私はWebサービスとメソッドを実装します。

@WebMethod(operationName = "testService") 
@WebResult(name="testServiceResponse") 
public TestServiceResponse testService(@WebParam(name = "params") TestService params){ 

    TestServiceResponse response = new TestServiceResponse(); 
    try { 
     response.setUyeKod(params.getUyeKod()); 
     response.setIslemRefNo(params.getIslemRefNo()); 
     response.setTestKod(params.getTestKod()); 
    } catch (Exception e) { 
     response.getHata().setAciklama(Convert.fromDBtoTR(TExceptionUtil.getExceptionMessage(e))); 
     response.getHata().setHataKodu("100"); 

    } 
    return response; 
} 

SAOP-UIでテストしてxsdをエクスポートした後、クライアントのリクエストは以下のようになります。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.ddd.ccc.bbb.aaa.com/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <ws:testService> 
     <params islemRefNo="1212" uyeKod="XXX" > 
      <testKod>1212</testKod> 
     </params> 
     </ws:testService> 
    </soapenv:Body> 
</soapenv:Envelope> 

しかし、私は私が

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.ddd.ccc.bbb.aaa.com/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <ws:testService islemRefNo="1212" uyeKod="XXX" > 
      <testKod>1212</testKod> 
     </ws:testService> 
    </soapenv:Body> 
</soapenv:Envelope> 

以下のように簡単には私のxsd下記のように見てみたい、のparamsタグを見たいと思ってはいけません。

<xs:complexType name="testService"> 
    <xs:sequence> 
    <xs:element name="params" minOccurs="0"> 
     <xs:complexType> 
     <xs:sequence> 
      <xs:element name="testKod" type="xs:string"/> 
     </xs:sequence> 
     <xs:attribute name="uyeKod" type="xs:string" use="required"/> 
     <xs:attribute name="islemRefNo" type="xs:string" use="required"/> 
    </xs:complexType> 
    </xs:element> 
    </xs:sequence> 
</xs:complexType> 

しかし、私はそのように見えます。また、私は同じ問題を応答XMLで直面した。

<xs:element name="testService"> 
     <xs:complexType> 
     <xs:sequence> 
      <xs:element name="testKod" type="xs:string"/> 
     </xs:sequence> 
     <xs:attribute name="uyeKod" type="xs:string" use="required"/> 
     <xs:attribute name="islemRefNo" type="xs:string" use="required"/> 
    </xs:complexType> 
</xs:element> 

答えて

1

どの種類のスタイルバインディング(RPCまたはドキュメント)を使用しているかによって異なります。次の注釈で指定できます。

私はあなたにとって最適な設定はRPC/Literalだと思います。

このガイドを参照してくださいhttps://www.ibm.com/developerworks/library/ws-whichwsdl/すべての方法の違いを確認する

関連する問題