首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >服务端点接口(SEI)

服务端点接口(SEI)
EN

Stack Overflow用户
提问于 2012-08-03 10:03:00
回答 1查看 12.2K关注 0票数 3

我创建了一个基本的web服务。假设我的服务器类有一个名为" status“的变量,它的SEI包含一个方法"getUpdate”,供客户端调用并获取状态。我如何在客户端编写代码来调用SEI方法"getUpdate"?

我的意思是,如果我在客户端使用port.Update,但我如何确定我引用的是哪个服务器实例?

提前谢谢。

SEI类:

代码语言:javascript
运行
复制
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();
}

服务器类:

代码语言:javascript
运行
复制
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;
    }
}
EN

回答 1

Stack Overflow用户

发布于 2014-02-13 17:53:52

您需要发布您创建的内容,以便您可以使用它。

代码语言:javascript
运行
复制
 Endpoint.publish("http://localhost:port/webservicepack", new webServiceimplementationClass);

然后创建一个客户端。

代码语言:javascript
运行
复制
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".

保重。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11788276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档