Java SOAP请求
在使用SOAP进行自我教育的过程中,我试图提出一个要求:Java SOAP请求,java,soap,wsdl,Java,Soap,Wsdl,在使用SOAP进行自我教育的过程中,我试图提出一个要求: 1.在测试中,我采用了交易员的api。 2.借助于maven-jaxb2-plugin生成的java类。 3.其中包括:ObjectFactory、TokenRequest、TokenResponse、GetInfoRequest 4.我正在通过ObjectFactory创建新对象,我认为我正在执行一个请求: ObjectFactory factory = new ObjectFactory(); TokenRequest tokenRe
1.在测试中,我采用了交易员的api。
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
为什么我在那里得到空值(我错过了什么吗)?我有什么要求吗?如果我真的成功了,我如何跟踪
我有什么要求吗
不,你不是在做请求,你只是在那里创建对象
在生成的类中签入名为ClientTradingService
和IClientTradingApi
的两个类,您必须使用它们来执行请求
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
要执行其他请求,流程与上面的流程完全相同
我有什么要求吗
不,你不是在做请求,你只是在那里创建对象
在生成的类中签入名为ClientTradingService
和IClientTradingApi
的两个类,您必须使用它们来执行请求
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
要执行其他请求,该过程与上面的过程完全相同。如果打开WSDL,那么在下面的部分中,您将找到WSDL:portType name=“IClientTradingApi”和 服务名称=“ClientTradingService”。 您必须使用这些类来调用服务。 下面的代码可能对您有所帮助
ObjectFactory factory = new ObjectFactory();
TokenRequest tokenRequest = factory.createTokenRequest();
tokenRequest.setLogin(12345);
tokenRequest.setPassword(factory.createTokenRequestPassword("password"));
ClientTradingService service = new ClientTradingService();
IClientTradingApi iClientTradingApi =
service.getBasicHttpBindingIClientTradingApi();
TokenResponse response =
iClientTradingApi.getAuthenticationToken(tokenRequest);
System.out.println(response);
如果打开WSDL,那么在下面的部分中,您将找到WSDL:portType name=“IClientTradingApi”和 服务名称=“ClientTradingService”。 您必须使用这些类来调用服务。 下面的代码可能对您有所帮助
ObjectFactory factory = new ObjectFactory();
TokenRequest tokenRequest = factory.createTokenRequest();
tokenRequest.setLogin(12345);
tokenRequest.setPassword(factory.createTokenRequestPassword("password"));
ClientTradingService service = new ClientTradingService();
IClientTradingApi iClientTradingApi =
service.getBasicHttpBindingIClientTradingApi();
TokenResponse response =
iClientTradingApi.getAuthenticationToken(tokenRequest);
System.out.println(response);
我得到了它。问题是我没有生成那些ClientTradingApi类。这可能是插件生成器的问题吗?@IgorZ有时它们不在同一个包中生成。实际上,maven plugin不提供该服务。我使用wsimport.exe-keep-verbosehttp://...wsdl 它使ClientTradingService.java成为其中之一。非常感谢,我知道了。问题是我没有生成那些ClientTradingApi类。这可能是插件生成器的问题吗?@IgorZ有时它们不在同一个包中生成。实际上,maven plugin不提供该服务。我使用wsimport.exe-keep-verbosehttp://...wsdl 它使ClientTradingService.java成为其中之一。非常感谢你。