Thursday, June 4, 2009

Java Types and Annotations for Web Services

Sometimes you want to send data between different applications, different programming languages, different machines etc.

One of the standard ways of doing so is using SOAP. Java has built in support for it, just define the following. And then call Endpoint.publish(url, new myClass()) and you're done.

@WebService()
@SOAPBinding(parameterStyle=ParameterStyle.WRAPPED,style=Style.RPC)
public class myClass {
@WebMethod(action="myMethod")
public myOutput myMethod(myInput p_input) {
}
}

Then of course you want your input and output to have some structure, so the other application and/or programming language would understand the WSDL.
For that, see the following reference
Mapping Java Types to XML and WSDL Types

No comments:

Post a Comment