Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I created a simple web service in Talend by following the (very well written, I must say) instructions here.
I named my service 'txn' and it accepts a numeric refNumber and returns the txn record from Mysql db. All works perfectly using SoapUI.
Now, I wanted to create a java web service client using Eclipse. The problem comes with passing the parameter to the web service. From the code generated by eclipse, the parameter is of type TxnOperationRequest, yet I want to pass an int type reference number. So I get the error:
The method txnOperation(TxnOperationRequest) in the type TxnPortType is not applicable for the arguments (int)
As far as I can tell, the types and methods are autogenerated in Talend, despite me setting the refNumber type to int when creating the service (see images below).
My question is how do I convert the parameter into usable types?
Edit:
I found where the problem was: I had not created an instance of type TxnOperationRequest
txnPortType txnService = locator.gettxnPort();
txnOperationRequest request = new txnOperationRequest(refNumber); //refNumber is an integer parameter being passed from the calling method
txnOperationResponse response = txnService.txnOperation(request); // request will be passed to the web service
System.out.println(response.getAccountNumber()); // use get methods to extract the fields from the webservice
Solved by ceating an instance of type txnOperationRequest:
txnPortType txnService = locator.gettxnPort(); txnOperationRequest request = new txnOperationRequest(refNumber); //refNumber is an integer parameter being passed from the calling method txnOperationResponse response = txnService.txnOperation(request); // request will be passed to the web service System.out.println(response.getAccountNumber()); // use get methods to extract the fields from the webservice
Solved by ceating an instance of type txnOperationRequest:
txnPortType txnService = locator.gettxnPort(); txnOperationRequest request = new txnOperationRequest(refNumber); //refNumber is an integer parameter being passed from the calling method txnOperationResponse response = txnService.txnOperation(request); // request will be passed to the web service System.out.println(response.getAccountNumber()); // use get methods to extract the fields from the webservice