Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web services cross-languages parameter types

I am creating a web service. I want to know how do I declare parameter type and use it as Java type is different for eg. date. I have written client to consume web services in Java which is working fine, but I want to know whether I can consume same web services using client written in some other language. I am giving you a code example of my web service:

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;

@WebService
public class WiseQuoteServer {
    @SOAPBinding(style = Style.RPC)
    public String getQuote(String category) {
        if (category.equals("fun")) {
            return "5 is a sufficient approximation of infinity.";
        }
        if (category.equals("work")) {
            return "Remember to enjoy life, even during difficult situatons.";
        } else {
            return "Becoming a master is relatively easily. Do something well and then continue to do it for the next 20 years";
        }
    }

    public static void main(String[] args) {
        WiseQuoteServer server = new WiseQuoteServer();
        Endpoint endpoint = Endpoint.publish(
                "http://localhost:9191/wisequotes", server);
    }
}
like image 994
Arvind Avatar asked Feb 11 '26 20:02

Arvind


1 Answers

Jigar is correct. JAX-WS uses JAXB to convert parameters into XML. JAXB has an extensive set of annotations that you can use to customize how the data is turned into XML. Since the data is sent as XML almost any language can read/write to the service. Furthermore, most languages have some kind of SOAP library available.

like image 66
Pace Avatar answered Feb 14 '26 10:02

Pace



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!