7 Replies Latest reply on Feb 8, 2009 1:41 AM by Benu Gupta

    Configure proxy auth to invoke an external web service from

    Benu Gupta Newbie

      Hi

      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.

        • 1. Re: Configure proxy auth to invoke an external web service f
          Benu Gupta Newbie

          Also as I noticed JBoss ESB's SoapClient download's wsdl at runtime. I was wondering if we could include the wsdl in the project build itself so that it doesn't have to download it every time. Also if the wsdl changes, it would break the project build.

          Any help would be greatly appreciated. Thanks.

          • 2. Re: Configure proxy auth to invoke an external web service f
            Daniel Bevenius Master

            Hi

            Does JBoss Esb support custom configurators?

            Just wanted to verify that you are following the steps defined on the this wiki page:
            http://www.jboss.org/community/docs/DOC-9969

            Can you post the contents of redcoal-http-8080.properties?
            Also which version are you using?

            The following works for me (modifying the https_2way_ssl quickstart):
            Configurator:
            package org.jboss.soa.esb.samples.https.server;
            
            import org.jboss.soa.esb.http.Configurator;
            import java.util.Properties;
            import org.apache.commons.httpclient.HttpClient;
            import org.jboss.soa.esb.ConfigurationException;
            
            public class CustomConfigurator extends Configurator
            {
             public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException
             {
             System.out.println("From Custom configure method....");
             }
            }


            Added the configurator to HttpRouter-localhost-https-9433.properties
            # Configurators
            configurators=HttpProtocol,org.jboss.soa.esb.samples.https.server.CustomConfigurator


            If you can modify the https_2way_ssl quickstart to display this error I'd be happy to take a look.

            regards,

            /Daniel


            • 3. Re: Configure proxy auth to invoke an external web service f
              Tom Fennelly Master

              Check the HttpClientFactory docs, specifically the section on implementing a custom Configurator.

              • 4. Re: Configure proxy auth to invoke an external web service f
                Benu Gupta Newbie

                Hi,

                I have been able to use my custom configurator after deleting the duplicate jar files (jbossesb-rosetta.jar and commons-httpclient-3.0.1.jar) from soapui-client.sar directory under my Jboss's deploy directory. These jar files are present in jbossesb.sar\lib and soap.esb folders respectively. As I mentioned earlier, I used to get the ClassCastException only when I would run my client (SendJMSMessage). I didn't get any exception while deploying the esb archive, though it was same piece of code (HttpClientFcatory.createHttpClient) run at both times. SoapUIClientService was using different set of classes then what were used at the time of deployment. Should there be any such duplicate jar files in any of the deployed esb folders?

                Now I have a different exception. The proxy server requires NTLM Auth. Can I use AuthNTLM as a configurator? I tried it but got the following exception:

                [HttpMethodDirector] I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
                14:33:19,533 INFO [HttpMethodDirector] Retrying request
                14:33:40,564 INFO [HttpMethodDirector] I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
                14:33:40,564 INFO [HttpMethodDirector] Retrying request
                14:34:01,690 INFO [HttpMethodDirector] I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
                14:34:01,690 INFO [HttpMethodDirector] Retrying request
                14:34:22,706 WARN [ActionProcessingPipeline] Unexpected exception caught while processing the action pipeline: header: [ To: JMSEpr .........]
                org.jboss.soa.esb.actions.ActionProcessingException: Failed to invoke SOAP Endpoint: 'http://xml.redcoal.com/soapserver.dll/soap/ISoapServer ' - 'SendTextSMS'.
                 at org.jboss.soa.esb.actions.soap.SOAPClient.invokeEndpoint(SOAPClient.java:468)
                 at org.jboss.soa.esb.actions.soap.SOAPClient.process(SOAPClient.java:416)
                 at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:316)
                 at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:530)
                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                 at java.lang.Thread.run(Unknown Source)
                Caused by: java.net.ConnectException: Connection timed out: connect
                 at java.net.PlainSocketImpl.socketConnect(Native Method)
                 at java.net.PlainSocketImpl.doConnect(Unknown Source)
                 at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
                 at java.net.PlainSocketImpl.connect(Unknown Source)
                 at java.net.SocksSocketImpl.connect(Unknown Source)
                 at java.net.Socket.connect(Unknown Source)
                 at java.net.Socket.connect(Unknown Source)
                 at java.net.Socket.<init>(Unknown Source)
                 at java.net.Socket.<init>(Unknown Source)
                 at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(Unknown Source)
                 at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(Unknown Source)
                 at org.apache.commons.httpclient.HttpConnection.open(Unknown Source)
                 at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(Unknown Source)
                 at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Unknown Source)
                 at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(Unknown Source)
                 at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source)
                 at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source)
                 at org.jboss.soa.esb.actions.soap.SOAPClient.invokeEndpoint(SOAPClient.java:460)
                 ... 6 more


                But when I use my custom configurator (HTTPProxyAuth), I get the following fault message in response:

                [STDOUT] *********** Configuring custom configurator: HTTPProxyAuth **************
                14:38:01,446 INFO [STDOUT] Progress: 1 - Caching definition from url [http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer]
                14:38:01,446 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include
                14:38:01,477 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema
                14:38:01,477 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace
                14:38:01,493 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd
                14:38:01,493 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime
                14:38:01,493 INFO [SchemaUtils] Added default schema from file:/D:/java/jboss-4.2.3.GA/server/default/tmp/deploy/tmp64742soapui-1.7.1.jar!/xmime200411.xsd with targetNamespace http://www.w3.org/2004/11/xmlmime
                14:38:01,493 INFO [SchemaUtils] Added default schema from D:/java/jboss-4.2.3.GA/server/default/data/soapui-schemas/XMLSchema1999.xsd with targetNamespace http://www.w3.org/1999/XMLSchema
                14:38:01,618 INFO [AuthChallengeProcessor] ntlm authentication scheme selected
                14:38:02,009 INFO [STDOUT] Progress: 1 - Loading definition from cache
                14:38:02,071 INFO [STDOUT] Retrieving document at 'http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer'.
                14:38:02,181 INFO [SchemaUtils] Loading schema types from [http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer]
                14:38:02,181 INFO [SchemaUtils] Getting schema http://xml.redcoal.com/soapserver.dll/wsdl/ISoapServer
                14:38:02,399 INFO [WsdlImporter] Finding importer for {http://tempuri.org/}ISOAPServerbinding
                14:38:02,399 INFO [WsdlImporter] Importing binding {http://tempuri.org/}ISOAPServerbinding
                14:38:02,462 INFO [Soap11HttpBindingImporter] importing endpoint http://xml.redcoal.com/soapserver.dll/soap/ISoapServer
                14:38:02,477 INFO [Soap11HttpBindingImporter] importing operation AddBase64MMSContent
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation AddMMSContent
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation CheckMessageStatus
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation CreateGroup
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation CreateMMS
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation DeleteSchedule
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation EnterSchedule
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation EnterScheduleExt
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetCreditsLeft
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetIncomingMessage
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetLicenseInformation
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetListEntries
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetListNames
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetMobileContentPreviewURL
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation GetPropertyPage
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation RedWebServiceVersion
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation RegisterAccount
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendBinarySMS
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendBinarySMSByContent
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendMMS
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendMobileContent
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendSMS2
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendTextSMS
                14:38:02,837 INFO [Soap11HttpBindingImporter] importing operation SendWAPSI
                14:38:03,040 INFO [AuthChallengeProcessor] ntlm authentication scheme selected
                14:38:03,181 WARN [SOAPClient] Received status code '500' on HTTP SOAP (POST) request to 'http://xml.redcoal.com/soapserver.dll/soap/ISoapServer'.
                14:38:03,181 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                14:38:03,181 INFO [STDOUT] Response Map is: {Fault.faultcode=SOAP-ENV:Server, Fault.faultstring=Unknown SOAPAction "SendTextSMS"}
                14:38:03,181 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


                Can anyone please help me to get this to work?

                Thanks Benu


                • 5. Re: Configure proxy auth to invoke an external web service f
                  Benu Gupta Newbie

                  Hi

                  I tried interception the soap message going over the wire using Wireshark. The soap message was being sent over 3 times for NTLM authentication. The last message carrying all the auth details was truncated at the end as follows and gave [ ERROR: Unrecognized text ]:

                  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:SOAPServerImpl-ISOAPServer"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   <soapenv:Header/>
                   <soapenv:Body>
                   <urn:SendTextSMS soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                   <strInSerialNo xsi:type="xsd:string">59</strInSerialNo>
                   <strInSMSKey xsi:type="xsd:string">H</strInSMSKey>
                   <strInRecipients xsi:type="xsd:string">+614335572</strInRecipients>
                   <strInMessageText xsi:type="xsd:string">Check your email.</strInMessageText>
                   <strInReplyEmail xsi:type="xsd:string">abc@def</strInReplyEmail>
                   <strInOriginator xsi:type="xsd:string">ABC</strInOriginator>
                   <iInType xsi:type="xsd:int">0</iInType>
                   <strOutMessageIDs xsi:type="xsd:string"/>
                   </urn:SendTextSMS>
                   </s oa


                  I guess this is the reason the response contains Unknown SOAPAction "SendTextSMS" fault message. Any ideas why this would happen???

                  Thanks Benu

                  • 6. Re: Configure proxy auth to invoke an external web service f
                    Tom Fennelly Master

                    So what happens when you take the ESB out of the equation? Reduce the number of moving parts by writing a simple test that only uses the HttpClientFactory, or even just create a HttpClient manually and manually configure it. You need to get this part working first, outside the ESB.

                    • 7. Re: Configure proxy auth to invoke an external web service f
                      Benu Gupta Newbie

                      Hi,

                      I have tried using a generic soap client - SoapUI to invoke the web service after configuring the proxy settings, and that works fine.

                      Thanks Benu.