【发布时间】:2021-05-28 13:13:27
【问题描述】:
我正在尝试通过 Azure 发送 SOAP 消息,我需要将订阅密钥添加到我的 JAX-WS 消息中。
NewSubscription_Service test = new NewSubscription_Service();
NewSubscription newSubscription = test.getNewSubscription();
WSBindingProvider binding = (WSBindingProvider) newSubscription;
binding.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapEndpointUrlAzure);
binding.setOutboundHeaders(
Headers.create(new QName("Ocp-Apim-Subscription-Key"),"xxx")
);
当我尝试发送此消息时,它会给我一个 401 并给出以下解释: 由于缺少订阅密钥,访问被拒绝。请确保在向 API 发出请求时包含订阅密钥。
我应该以其他方式添加标题吗?我不太习惯 SOAP 消息,因此欢迎提供任何帮助。
【问题讨论】: