如何在Spring的WebServiceGatewaySupport
中设置用户代理?这是我已经尝试但失败的原因:
@Bean
public DiscreteGateway discreteGateway() throws SOAPException {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setContextPath(CONTEXT_PATH);
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("User-Agent", "Tough-User");
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL));
messageFactory.setMessageProperties(propertyMap);
DiscreteGateway discreteGateway = new DiscreteGateway();
discreteGateway.setMarshaller(jaxb2Marshaller);
discreteGateway.setUnmarshaller(jaxb2Marshaller);
discreteGateway.setMessageFactory(messageFactory);
discreteGateway.setDefaultUri(Discrete_URI);
return discreteGateway;
}
请注意DiscreteGateway
扩展WebServiceGatewaySupport
...