Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Endpoint Interface (SEI)

I have a basic web service created. Let's say my server class has a variable called "status", and its SEI contain a method "getUpdate" for client to call and get the status? How do I code this out at the client side to call the SEI method "getUpdate"?

What I mean if I use port.Update at the client side but how do I determine which server instance I am referring to?

Thanks in advance.

SEI class:

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();
}

Server class:

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;
    }
}
like image 367
keithwb Avatar asked Mar 27 '26 02:03

keithwb


1 Answers

You need to publish what you have created so that you can consume it.

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

Then create a client.

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

Take care.

like image 151
GiorgoCH Avatar answered Mar 28 '26 15:03

GiorgoCH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!