在wcf和c中,有一个httprequestmessageproperty,序列化后如下所示:
{Authorization: Basic V6ZFSVRHLU2ESVSvV4PVr8Vy6kRcs145b5dvTMg=
UniqueId: 1eca77ed-dd9f-4e0f-9312-a917c20b805f
CallKey: 2
Timestamp: 2020-12-07T16:33:38.9808498+01:00
username: MyUsername
password: MySecretPassword
}
当我在我的.net应用程序中进行服务调用时,这会添加到我的soap头中,它的工作方式就像一个符咒。
虽然我试图在java应用程序的客户机代码中添加这些头值作为请求的一部分,但是我找不到方法将这些键/值对添加到java中现有的soap头中。
我在网上看过一些例子,但没有成功。
我试过这个:
URL url = new URL("http://myservicereference_url");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestProperty ("Authorization", authorizationHeader);
httpURLConnection.setRequestProperty("Timestamp", new Date().toString());
httpURLConnection.setRequestProperty("UniqueId", UUID.randomUUID().toString());
httpURLConnection.setRequestProperty("CallKey", "2");
httpURLConnection.setRequestProperty("Timestamp", new Date().toString());
httpURLConnection.setRequestProperty("username", username);
httpURLConnection.setRequestProperty("password", password);
有人能给我一个提示吗?
暂无答案!
目前还没有任何答案,快来回答吧!