服务端点接口(SEI)

服务端点接口(SEI)

问题描述:

我有一个基本的Web服务创建。假设我的服务器类有一个名为“status”的变量,并且它的SEI包含一个方法“getUpdate”供客户端调用并获取状态?如何在客户端对此进行编码以调用SEI方法“getUpdate”?服务端点接口(SEI)

我的意思是如果我在客户端使用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; 
    } 
} 

您需要发布你创造了什么,这样就可以使用它。

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". 

保重。