In the course of my self education with SOAP I am trying to make a request:
1. For my tests I took a trader's api wsdl.
2. With the help of maven-jaxb2-plugin
generated java classes.
3. Among the others there are such as: ObjectFactory, TokenRequest, TokenResponse, GetInfoRequest
.
4. I am making new objects through the ObjectFactory
and as I think I am doing a request:
ObjectFactory factory = new ObjectFactory();
TokenRequest tokenRequest = factory.createTokenRequest();
tokenRequest.setLogin(12345);
tokenRequest.setPassword(factory.createTokenRequestPassword("password"));
TokenResponse tokenResponse = factory.createTokenResponse();
GetInfoRequest getInfoRequest = factory.createGetInfoRequest();
getInfoRequest.getLogin(); //It's null
Why do I get null there (have I missed something)? Do I even make a request? How can I track if I really make it?
Do I even make a request?
No, you are not doing a request, you are just creating objects over there
check in your generated classes for two classes called ClientTradingService
and IClientTradingApi
you have to use those to do the request.
ObjectFactory factory = new ObjectFactory();
TokenRequest tokenRequest = factory.createTokenRequest();
tokenRequest.setLogin(12345);
tokenRequest.setPassword(factory.createTokenRequestPassword("password"));
//create your service should be something similar to this
ClientTradingService service = new ClientTradingService();
IClientTradingApi iservice = service.getBasicHttpBindingIClientTradingApi();
//do your request should be something similar to this
TokenResponse tokenResponse = iservice.getAuthenticationToken(tokenRequest);
//now you can get the info from the response
tokenResponse.getToken();//this should return the authentication token
To do some other request the process is exactly as the one above.