3

基本的なWebサービスを作成しました。サーバークラスに「status」という変数があり、そのSEIに、クライアントが呼び出してステータスを取得するためのメソッド「getUpdate」が含まれているとします。これをクライアント側でコード化して、SEIメソッド「getUpdate」を呼び出すにはどうすればよいですか?

クライアント側でport.Updateを使用する場合、どういう意味ですか?参照しているサーバーインスタンスを特定するにはどうすればよいですか?

前もって感謝します。

SEIクラス:

package com.basic.ws;

import javax.jws.WebService;

@WebService(name = "Server_SEI", targetNamespace = "http://ws.basic.com/")
public interface Server_SEI {

    public int sum(int x, int y);

    public String getUpdate();
}

サーバークラス:

package com.basic.ws;

import javax.jws.WebService;

@WebService(targetNamespace = "http://ws.basic.com/", endpointInterface = "com.basic.ws.Server_SEI", portName = "ServerPort", serviceName = "ServerService")
public class Server implements Server_SEI{
    String status = "OK";

    public void setTrafficStatus(String status){
        this.status = status;
    }
    public String getUpdate(){
        return status;
    }
}
4

1 に答える 1

2

作成したものを公開して、消費できるようにする必要があります。

 Endpoint.publish("http://localhost:port/webservicepack", new webServiceimplementationClass);

次に、クライアントを作成します。

URL url = new URL("http://localhost:port/webServicepack?wsdl");

    //here is the service consuming
    QName qName = new QName("http://webservicepackage/", "webserviceimplementationsclass");

    // Qualified name of the service:
    //   1st arg is the service URI
    //   2nd is the service name published in the WSDL

    Service service = Service.create(url, qName);

    // Create, in effect, a factory for the service.
    TimeServer eif = service.getPort(ServiceClient.class);
    // Extract the endpoint interface, the service "port".

気をつけて。

于 2014-02-13T09:53:51.613 に答える