Java SOAP 请求

标签 java soap wsdl

在我自学 SOAP 的过程中,我试图提出一个请求:
1. 为了进行测试,我使用了交易者的 api wsdl .
2.借助maven-jaxb2-plugin生成java类。
3. 其中包括:ObjectFactory、TokenRequest、TokenResponse、GetInfoRequest
4. 我正在通过 ObjectFactory 创建新对象,并且我认为我正在执行一个请求:

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

为什么我在那里得到空(我错过了什么)?我什至提出要求吗?如何追踪我是否真的成功了?

最佳答案

Do I even make a request?

不,您没有执行请求,您只是在那里创建对象

检查生成的类中是否有两个名为 ClientTradingServiceIClientTradingApi 的类,您必须使用它们来执行请求。

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 

要做其他一些请求,过程与上面的完全一样。

关于Java SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44314631/

相关文章:

json - ASP.NET web api : documenting/specifying a service

php - Python SOAP 客户端、授权

Java:将配置变量存储在文件中

magento Soap api 仅适用于 https

java - Astyanax cql3 COUNT 查询返回 ROWS 而不是 NUMBER

python - 通过 SOAP v2 创建 Magento 产品

Java - 以编程方式从给定的 WSDL 创建 SOAP

web-services - 当有其他提供者时,如何在消费者端为 1 个提供者添加元素到 WS 操作?

java - java中如何将大整数转换为Ascii字符串?

java - 链接结构