One Star

How can I configure http basic auth in a web service ?

This post is a sum up of a question posted on StackOverflow : http://stackoverflow.com/q/19449771/15619
As an example, I have an About web-service, which only method getVersion return the application version.
I can easily call it through SoapUI but, accessing it through a Job in Talend seems impossible.
Indeed, each time I run my job, it ends with the following error
Démarrage du job About a 14:04 18/10/2013.
connecting to socket on port 4025
connected
Exception in component tWebService_1
org.apache.ws.commons.schema.XmlSchemaException: Server returned HTTP response code: 401 for URL: http://localhost:8080/digital-express-soap/AboutService?xsd=1
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:710)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:706)
at org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:538)
at org.apache.ws.commons.schema.SchemaBuilder.handleSchemaElementChild(SchemaBuilder.java:1513)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:659)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:540)
at org.talend.webservice.helper.ServiceDiscoveryHelper.getSchemaCollection(ServiceDiscoveryHelper.java:363)
at org.talend.webservice.helper.ServiceDiscoveryHelper.init(ServiceDiscoveryHelper.java:130)
at org.talend.webservice.helper.ServiceDiscoveryHelper.<init>(ServiceDiscoveryHelper.java:90)
at org.talend.webservice.helper.ServiceInvokerHelper.<init>(ServiceInvokerHelper.java:98)
at test_lct.about_0_1.About.tWebService_1Process(About.java:300)
at test_lct.about_0_1.About.runJobInTOS(About.java:559)
at test_lct.about_0_1.About.main(About.java:425)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/digital-express-soap/AboutService?xsd=1
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at org.apache.ws.commons.schema.XmlSchemaCollection$2.run(XmlSchemaCollection.java:738)
at org.apache.ws.commons.schema.XmlSchemaCollection$2.run(XmlSchemaCollection.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.ws.commons.schema.XmlSchemaCollection.parseDoPriv(XmlSchemaCollection.java:736)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:705)
... 12 more
disconnected
So it appears my server don't accept the provided auth. What is really strange, given that debugging my realm reveals that some authenticated calls are made. However, it also seems the last call is unauthorized. Why ?
I did some more tests by enabling HTTP logging in Glassfish, then perform one test for each tool.
Using soapui, I get
"127.0.0.1" "NULL-AUTH-USER" "07/Nov/2013:10:45:51 +0100" "POST /digital-express-soap/AboutService HTTP/1.1" 401 1069
"127.0.0.1" "admin" "07/Nov/2013:10:45:51 +0100" "POST /digital-express-soap/AboutService HTTP/1.1" 200 247
And using Talend Open Studio for Data Integration 5.3.1, I get
"127.0.0.1" "NULL-AUTH-USER" "07/Nov/2013:11:03:27 +0100" "POST /digital-express-soap/AboutService HTTP/1.1" 401 1069
"127.0.0.1" "admin" "07/Nov/2013:11:03:27 +0100" "POST /digital-express-soap/AboutService HTTP/1.1" 200 247
which, as far as I know, is exactly the same. So the order in which queries are made to my server is the same, but the way the client interprets it change.
So, what am I doing wrong with Talend which prevent it from using my auth ?
2 REPLIES
Community Manager

Re: How can I configure http basic auth in a web service ?

Hi
Can you please upload a screenshot of the component settings? It will be useful for us to find out the problem. In addition, you can try tSOAP component and see if this component works.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How can I configure http basic auth in a web service ?

Here is the configuration of my tWebService.
I've already seen that tSOAP is working in such a config. Unfortunatly, tSOAP requires us to write the full XML message by ahnd, which is not acceptable.
However, considering tSOAP could open an http authenticated session, I had the idea to call tSOAP then tWebService, which worked. As a consequence, I used a pure http request, using http auth basic, then a call to tWebService, which worked.
I conbsider this is due to the fact that Talend using CXF, uses apache commons http client, which, as far as I know, supports http session and as a consequence can make the web service call in the authenticated http session.
However, I tend to consider this as a bugged behaviour, as making a basic http call just to allow the authentication in a web service scenario is far from optimal.