A
A
Alexiuscrow2017-09-05 14:36:19
Java
Alexiuscrow, 2017-09-05 14:36:19

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();
    }
}

Spring context:
<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>

Client usage:
public class App {
    @Autowired
    private MyWebServiceAPI wsClient;

    public void someMethod() {
        wsClient.getSomeInfo();
        // Need to know http response code from `wsClient.getSomeInfo()`
    }
}

How can I get response code from soap web service?
I can specify an interceptor for 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

1 answer(s)
A
Alexiuscrow, 2017-09-05
@Alexiuscrow

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 question

Ask a Question

731 491 924 answers to any question