sách gpt4 ai đã đi

Java SOAP 请求

In lại 作者:行者123 更新时间:2023-12-02 02:47:59 26 4
mua khóa gpt4 Nike

在我自学 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

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

1 Câu trả lời

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/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com