0

5 種類のサービスを作成しました。A、B、C、D、E。Apache 軸の使用

単一の Java クライアントから、これら 5 つのサービスすべてを呼び出し、各サービスに 3 つの引数を与えます。

クライアントを作成しました。このままですよね?

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class ServicesCaller 
{

    String A="";
    String B="";
    String C="";

    public void services(String start,String end,String comfort)
    {
         try 
         {
            String endpoint1="http://localhost:8080/callser/services/A1";
            String endpoint2="http://localhost:8080/callser/services/A2";
            String endpoint3="http://localhost:8080/callser/services/A3";
            String endpoint4="http://localhost:8080/callser/services/A4";
            String endpoint5="http://localhost:8080/callser/services/A5";

            Service service=new Service();

            Call call=(Call)service.createCall();

            call.setTargetEndpointAddress(new java.net.URL(endpoint1));
            call.setTargetEndpointAddress(new java.net.URL(endpoint2));
            call.setTargetEndpointAddress(new java.net.URL(endpoint3));
            call.setTargetEndpointAddress(new java.net.URL(endpoint4));
            call.setTargetEndpointAddress(new java.net.URL(endpoint5));

            call.setOperationName(new QName("http://service.com","firstReturn"));

            String ret = (String) call.invoke( new Object[] {start,end,comfort} );

         }

         catch(Exception e)
         {
             System.out.println(e);
         }
    }
}

それが正しいか?jspから実行すると、この例外が発生します

org.xml.sax.SAXException: Deserializing parameter 'arg0':  could not find deserializer for type {http://schemas.xmlsoap.org/soap/encoding/}string
4

1 に答える 1

0

最初に、IDE を使用して、各 Web サービス WSDL のサブを作成します。スタブを取得したら、それらのダミー メソッドを呼び出すだけです。これにより、時間と労力を大幅に節約できます。

次に、コードに従って以下のコード ロジックを使用すると、すべての WS を呼び出すことはできず、最後の 1 つだけを呼び出すことができます。

IDE がない場合は、Net Beans または oracle Jdev をダウンロードしてください。どちらもフリーウェアであり、それができない場合でもライセンスは必要ありません。その場合でも、WSImport が最適なオプションです。

public class ServicesCaller 
{

    String A="";
    String B="";
    String C="";

    public void services(String start,String end,String comfort)
    {
         try 
         {
            String endpoint1="http://localhost:8080/callser/services/A1";
            String endpoint2="http://localhost:8080/callser/services/A2";
            String endpoint3="http://localhost:8080/callser/services/A3";
            String endpoint4="http://localhost:8080/callser/services/A4";
            String endpoint5="http://localhost:8080/callser/services/A5";

            Service service=new Service();

            Call call=(Call)service.createCall();

            String ret ="";
            call.setOperationName(new QName("http://service.com","allepyReturn"));

            call.setTargetEndpointAddress(new java.net.URL(endpoint1));
            ret = (String) call.invoke( new Object[] {start,end,comfort} );

            call.setTargetEndpointAddress(new java.net.URL(endpoint2));
            ret = (String) call.invoke( new Object[] {start,end,comfort} );

            call.setTargetEndpointAddress(new java.net.URL(endpoint3));
            ret = (String) call.invoke( new Object[] {start,end,comfort} );

            call.setTargetEndpointAddress(new java.net.URL(endpoint4));
            ret = (String) call.invoke( new Object[] {start,end,comfort} );

            call.setTargetEndpointAddress(new java.net.URL(endpoint5));
            ret = (String) call.invoke( new Object[] {start,end,comfort} );

         }

         catch(Exception e)
         {
             System.out.println(e);
         }
    }
于 2013-03-05T20:59:08.657 に答える