I have made a custom web service in Java just like the one described on the Mirth wiki
There are few methods defined in the web service class, but I don't know how to configure Mirth to listen to different methods of a single web service. Are there any tutorials on this matter? How do I define different input and output data for different methods?
You can use the @javax.jws.WebMethod
and @javax.jws.WebParam
annotations in your class that extends AcceptMessage
, and your return value can be any class that you've appropriately decorated as XML. Something like:
package mypackage.myservices;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.mirth.connect.connectors.ws.AcceptMessage;
import com.mirth.connect.connectors.ws.WebServiceReceiver;
@WebService
public class QueryService extends AcceptMessage {
public QueryService(WebServiceReceiver webServiceReceiver) {
super(webServiceReceiver);
}
@WebMethod(action="Authenticate")
public AuthResponse authenticate(@WebParam(name="Username") String username,
@WebParam(name="Password") String password) {
//authenticate your user and return an AuthResponse,
//possibly containing a token for use in subsequent calls...
return new AuthResponse();
}
@WebMethod(action="GetResponse")
public QueryResponse getResponse(@WebParam(name="QueryObject") Query query) {
//handle the Query object, use it to get data from a DB, or whatever
return new QueryResponse(); // or an appropriate Response object
}
}
Where your AuthResponse
, Query
and QueryResponse
objects can be any appropriately decorated (with java.xml.bind.annotation...
) objects you like. Your methods will then be described in the WSDL (which Mirth gives you the address of in the Connector), so your service can be consumed by third parties.