Configure proxy auth to invoke an external web service from
bains Feb 3, 2009 6:13 PMHi
I need to invoke a web service on the internet from behind the firewall. I had a look at the built-in configurators and tried HttpProtocol but that didn't work probably since it does not support the setting of credentials on HttpClient. I kept getting the following error:
Caused by: java.io.IOException: Failed to import WSDL 'http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer'. at org.jboss.soa.esb.services.soapui.SoapUIClientService.getWsdlInterfaces(SoapUIClientService.java:318) at org.jboss.soa.esb.services.soapui.SoapUIClientService.getOperation(SoapUIClientService.java:325) at org.jboss.soa.esb.services.soapui.SoapUIClientService.buildRequest(SoapUIClientService.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.soa.esb.actions.soap.MBeanSoapUIInvoker.buildRequest(MBeanSoapUIInvoker.java:72) at org.jboss.soa.esb.actions.soap.SOAPClient.process(SOAPClient.java:409) ... 5 more Caused by: com.eviware.soapui.support.SoapUIException: Error importing wsdl at com.eviware.soapui.impl.wsdl.WsdlProject.importWsdl(WsdlProject.java:424) at com.eviware.soapui.impl.wsdl.WsdlProject.importWsdl(WsdlProject.java:402) at org.jboss.soa.esb.services.soapui.SoapUIClientService.getWsdlInterfaces(SoapUIClientService.java:313) ... 18 more Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
I tried writing my own Configurator based on HttpProtocol and modified the configure method so as to set the ProxyCredentials on HttpClient. Abstract below:
public class HTTPProxyAuth extends Configurator { . . . public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException { . . . //set proxy Credentials final String proxyUsername = (String) properties.get("http.proxyUsername"); final String proxyPassword = (String) properties.get("http.proxyPassword"); UsernamePasswordCredentials upc = new UsernamePasswordCredentials(proxyUsername, proxyPassword ); httpClient.getState().setProxyCredentials(AuthScope.ANY, upc); . . . } . . . }
The action that invokes the web service has been configured as follows:
<action class="org.jboss.soa.esb.actions.soap.SOAPClient" name="soapui-client-action"> <property name="wsdl" value="http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer"> <http-client-property name="file" value="/META-INF/redcoal-http-8080.properties" /> </property> <property name="SOAPAction" value="SendTextSMS"/> <property name="responseAsOgnlMap" value="true" /> </action>
But now every time I run my client I get the following exception:
Caused by: java.io.IOException: Failed to import WSDL 'http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer'. at org.jboss.soa.esb.services.soapui.SoapUIClientService.getWsdlInterfaces(SoapUIClientService.java:318) at org.jboss.soa.esb.services.soapui.SoapUIClientService.getOperation(SoapUIClientService.java:325) at org.jboss.soa.esb.services.soapui.SoapUIClientService.buildRequest(SoapUIClientService.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.soa.esb.actions.soap.MBeanSoapUIInvoker.buildRequest(MBeanSoapUIInvoker.java:72) at org.jboss.soa.esb.actions.soap.SOAPClient.process(SOAPClient.java:409) ... 5 more Caused by: org.jboss.soa.esb.ConfigurationException: Class [au.gov.dha.HTTPProxyAuth] must extend [org.jboss.soa.esb.http.Configurator]. at org.jboss.soa.esb.http.HttpClientFactory.createConfigurator(HttpClientFactory.java:98) at org.jboss.soa.esb.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:87) at org.jboss.soa.esb.services.soapui.SoapUIClientService.createWsdlLoader(SoapUIClientService.java:351) at org.jboss.soa.esb.services.soapui.SoapUIClientService.getWsdlInterfaces(SoapUIClientService.java:313) ... 18 more Caused by: java.lang.ClassCastException: org.HTTPProxyAuth cannot be cast to org.jboss.soa.esb.http.Configurator at org.jboss.soa.esb.http.HttpClientFactory.createConfigurator(HttpClientFactory.java:96)
Does JBoss Esb support custom configurators? Or is there any other way I can specify the proxy details for invoking an external web service?
Thanks Benu.