Answer the question
In order to leave comments, you need to log in
How to get Http respose code in soap client?
There is a soap web service and a client that interacts with it.
The Apache CXF/Spring bundle is used for implementation.
Customer:
public class MyWebServiceClientFactoryCXF {
public MyWebServiceAPI getMyWebServiceClient(String URI, String username, String password) throws MalformedURLException {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(MyWebServiceAPI.class);
factory.setAddress(URI);
factory.setUsername(username);
factory.setPassword(password);
factory.setDataBinding(new AegisDatabinding());
return (MyWebServiceAPI) factory.create();
}
}
<bean id="myWebServiceClientFactory" class="mypakg.MyWebServiceClientFactoryCXF"/>
<bean id="myWebServiceClient" factory-bean="myWebServiceClientFactory" factory-method="getMyWebServiceClient">
<constructor-arg index="0" type="java.lang.String" value="${ws.url}"/>
<constructor-arg index="1" type="java.lang.String" value="${ws.login}"/>
<constructor-arg index="2" type="java.lang.String" value="${ws.pwd}"/>
</bean>
public class App {
@Autowired
private MyWebServiceAPI wsClient;
public void someMethod() {
wsClient.getSomeInfo();
// Need to know http response code from `wsClient.getSomeInfo()`
}
}
JaxWsProxyFactoryBean
, but how do I pass the value from the interceptor to the method App.someMethod()
?
Answer the question
In order to leave comments, you need to log in
public void someMethod() {
wsClient.getSomeInfo();
Client client = ClientProxy.getClient(wsClient);
Integer responseCode = client.getResponseContext().get(Message.RESPONSE_CODE);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question