Reputation: 7008
For example, I have to create a webservice with a details below:
Webservice name is WS1 Method name is initiateBatchProcess (String Status, int BatchID)
I have tried the following with one parameter, but how do I do it with two parameters and return it in the response of webservice/soap
public class WS1
{
int status;
@WebMethod(operationName="status")
public int status(int status) {
return status;
}
}
Upvotes: 1
Views: 3149
Reputation: 780
You simply add another parameter. The use of the @WebParam is optional, keep it if you want or ditch it.
@WebMethod(operationName="initBatch")
public void initiateBatchProcess(@WebParam(name = "Status") String Status,
@WebParam(name = "Batch") int BatchID) {
//do stuff
}
LE:
So, if you want to send back more than one thing, the best solution i can think of is encapsulating those things into a single object.
@WebMethod(operationName="initBatch")
public RezultSet initiateBatchProcess(String status, int batchID) {
//do stuff
ResultSet result = new ResultSet();
result.setStatus(status);
result.setBatchId(batchID);
return result;
/*
*Or you can do something like
*return new ResultSet(status, batchID);
*/
}
And ResultSet is just a simple bean with 2 members.
public class ResultSet {
private String status;
private int batchID;
// getters, setters, constructors
}
Upvotes: 5