2

Java インターフェイス ファイルを活用して、スタブ クラスを生成せずに軸 Web サービスを呼び出す方法はありますか? 私たちは両方の側 (クライアントとサーバー) を制御します。

4

1 に答える 1

1

はい、 org.apache.axis2.client.ServiceClientを使用して「アドホック」クライアントを使用できます。こんな感じです。

import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import java.net.URL;


...
String endpoint = "http://wsendpoint.com/ServiceName"
 QName operation = new QName("http://namespace","WsRequest");               
             OMElement payload = buildPayload("requestdata");


 try{
                   ServiceClient sender= new ServiceClient(
                            null,
                            new URL(endpoint),
                            null,
                            null);
                   OMElement result = sender.sendReceive(operation,payload);
           logger.debug("response is:" + result.toString());                                   

                    }

             }catch (Exception e)  {
                 logger.debug("exception caught: " + e.getMessage());
             }
于 2010-01-13T18:15:04.407 に答える