I am developing a java client for a web service.
I have this method in my web service:
@WebMethod(operationName = "test")
public Integer test(@WebParam(name = "number")
int number) {
return number;
}
My client looks like this
public static void main(String[] args) {
try {
String BODY_NAMESPACE_VALUE = /namespace url/;
QName port = new QName(/Service name/);
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(/Service name/));
Call call = service.createCall(port);
call.setTargetEndpointAddress(/WSDL location/);
call.setReturnType(XMLType.XSD_I开发者_StackOverflow社区NT);
call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "test"));
call.addParameter("number", XMLType.XSD_INT, ParameterMode.IN);
Integer[] i = new Integer[1];
i[0] = new Integer(20);
System.out.println("test :"+call.invoke(i));
} catch (Exception ex) {
ex.printStackTrace();
}
}
I get return values ok from the web service in my java client since I tried getting a constant from the web service. However, in the case above I am trying to send 20 from the client to the web service and receive it back. However I am receiving 0. Does anyone know why sending parameters from client to web service is not working?
Thanks and regards, Krt_Malta
I don't know if this is the answer but it appears as though you are sending the webservice an array of Integers
Integer[] i;
when it is only expecting a single int
.
精彩评论