You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Axel Becker <ax...@becker-coding.de> on 2007/07/25 23:27:40 UTC

HTTP Basic Auth with wsdl2java generated Client

Hi,

i generated the client code with the wsdl2java from an existing wsdl.

now i want to connect to this service (it is an axis 1 webservice). the
service ist protected with a http basic authentication. i use the following
code, but it doesnt work :-(

INFOServiceService ss = new INFOServiceService(SERVICE_URL, SERVICE_NAME);

Client client = ClientProxy.getClient(ss.getINFOService());
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
			
httpConduit.getAuthorization().setUserName("username1");
httpConduit.getProxyAuthorization().setUserName("username1");
			
INFOService service = ss.getINFOService();
//do somthing with service

Where is the mistake?

Thanks for your help!
Axel


PS: the serverside (axis1) code to get the auth parameter is:
String username = MessageContext.getCurrentContext().getUsername();


-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11800307
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Fred Dushin <fr...@dushin.net>.
Axel,

You might also try something like:

{{{
import org.apache.cxf.configuration.security.AuthorizationPolicy;
...

         AuthorizationPolicy authzPolicy =
             new AuthorizationPolicy();
         authzPolicy.setUserName("foo");
         authzPolicy.setPassword("bar");
         bp.getRequestContext().put(
             AuthorizationPolicy.class.getName(),
             authzPolicy
         );
}}}

Where bp is the Jax-ws BindingProvider Dan mentioned earlier.

On Jul 26, 2007, at 5:27 PM, Daniel Kulp wrote:

> I'm going to go ahead and fix that.   I have no idea why your stuff  
> isn't
> appearing on the wire at all.   That's very strange.   :-(


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Daniel Kulp <dk...@apache.org>.
I just edited our system test to just send the username and it seems to 
encode it on the wire.   Actually, it's encoding it on the wire twice.   
There are two Authorization headers.   :-(

I'm going to go ahead and fix that.   I have no idea why your stuff isn't 
appearing on the wire at all.   That's very strange.   :-(

Dan



On Thursday 26 July 2007 04:31, Daniel Kulp wrote:
> Are you just setting a username and no password?
>
> I'm wondering if that's the issue.   I'm not sure if we deal with
> that. Just for kicks, could you add a password in and see if the
> tcpmon dump has the auth stuff?   If so, then I at least know where to
> start looking.
>
> Dan
>
> On Thursday 26 July 2007 04:14, Axel Becker wrote:
> > Hi Dan,
> >
> > this doenst work too :-(
> >
> > following the trace from tcpmon:
> >
> > POST /GDHSService/services/INFOService HTTP/1.1
> > Content-Type: text/xml; charset=UTF-8
> > SOAPAction: ""
> > Cache-Control: no-cache
> > Pragma: no-cache
> > User-Agent: Java/1.5.0_11
> > Host: localhost:9090
> > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> > Connection: keep-alive
> > Transfer-Encoding: chunked
> >
> > 18c
> > <soap:Envelope
> > mlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
> >   <ns2:getCompanies
> >     xmlns="http://xml.apache.org/xml-soap"
> >     xmlns:ns2="http://webservices.impl.service.prj.beckercoding.de"
> >     xmlns:ns3="http://bean.transfer.services.beckercoding.de"
> >
> > xmlns:ns4="http://127.0.0.1:9090/GDHSService/services/INFOService">
> > <ns2:gmId>1</ns2:gmId>
> >    </ns2:getCompanies>
> >   </soap:Body>
> > </soap:Envelope>
> > 0
> >
> >
> > Thanks for your help
> > Axel
> >
> > dkulp wrote:
> > > Alex,
> > >
> > > Could you try the JAX-WS standard way of setting the
> > > username/password?
> > >
> > > INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> > >                 SERVICE_NAME);
> > > INFOService port = ss.getINFOService();
> > > BindingProvider bp = (BindingProvider)port;
> > > bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
> > > "BJ");
> > > bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
> > > "pswd");
> > >
> > >
> > > Dan
> > >
> > > On Wednesday 25 July 2007 17:27, Axel Becker wrote:
> > >> Hi,
> > >>
> > >> i generated the client code with the wsdl2java from an existing
> > >> wsdl.
> > >>
> > >> now i want to connect to this service (it is an axis 1
> > >> webservice). the service ist protected with a http basic
> > >> authentication. i use the following code, but it doesnt work :-(
> > >>
> > >> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> > >> SERVICE_NAME);
> > >>
> > >> Client client = ClientProxy.getClient(ss.getINFOService());
> > >> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> > >>
> > >> httpConduit.getAuthorization().setUserName("username1");
> > >> httpConduit.getProxyAuthorization().setUserName("username1");
> > >>
> > >> INFOService service = ss.getINFOService();
> > >> //do somthing with service
> > >>
> > >> Where is the mistake?
> > >>
> > >> Thanks for your help!
> > >> Axel
> > >>
> > >>
> > >> PS: the serverside (axis1) code to get the auth parameter is:
> > >> String username =
> > >> MessageContext.getCurrentContext().getUsername();
> > >
> > > --
> > > J. Daniel Kulp
> > > Principal Engineer
> > > IONA
> > > P: 781-902-8727    C: 508-380-7194
> > > daniel.kulp@iona.com
> > > http://www.dankulp.com/blog

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Daniel Kulp <dk...@apache.org>.

Are you just setting a username and no password?   

I'm wondering if that's the issue.   I'm not sure if we deal with that.   
Just for kicks, could you add a password in and see if the tcpmon dump 
has the auth stuff?   If so, then I at least know where to start 
looking.

Dan

On Thursday 26 July 2007 04:14, Axel Becker wrote:
> Hi Dan,
>
> this doenst work too :-(
>
> following the trace from tcpmon:
>
> POST /GDHSService/services/INFOService HTTP/1.1
> Content-Type: text/xml; charset=UTF-8
> SOAPAction: ""
> Cache-Control: no-cache
> Pragma: no-cache
> User-Agent: Java/1.5.0_11
> Host: localhost:9090
> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> Connection: keep-alive
> Transfer-Encoding: chunked
>
> 18c
> <soap:Envelope mlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>  <soap:Body>
>   <ns2:getCompanies
>     xmlns="http://xml.apache.org/xml-soap"
>     xmlns:ns2="http://webservices.impl.service.prj.beckercoding.de"
>     xmlns:ns3="http://bean.transfer.services.beckercoding.de"
>    
> xmlns:ns4="http://127.0.0.1:9090/GDHSService/services/INFOService">
> <ns2:gmId>1</ns2:gmId>
>    </ns2:getCompanies>
>   </soap:Body>
> </soap:Envelope>
> 0
>
>
> Thanks for your help
> Axel
>
> dkulp wrote:
> > Alex,
> >
> > Could you try the JAX-WS standard way of setting the
> > username/password?
> >
> > INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> >                 SERVICE_NAME);
> > INFOService port = ss.getINFOService();
> > BindingProvider bp = (BindingProvider)port;
> > bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "BJ");
> > bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
> > "pswd");
> >
> >
> > Dan
> >
> > On Wednesday 25 July 2007 17:27, Axel Becker wrote:
> >> Hi,
> >>
> >> i generated the client code with the wsdl2java from an existing
> >> wsdl.
> >>
> >> now i want to connect to this service (it is an axis 1 webservice).
> >> the service ist protected with a http basic authentication. i use
> >> the following code, but it doesnt work :-(
> >>
> >> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> >> SERVICE_NAME);
> >>
> >> Client client = ClientProxy.getClient(ss.getINFOService());
> >> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> >>
> >> httpConduit.getAuthorization().setUserName("username1");
> >> httpConduit.getProxyAuthorization().setUserName("username1");
> >>
> >> INFOService service = ss.getINFOService();
> >> //do somthing with service
> >>
> >> Where is the mistake?
> >>
> >> Thanks for your help!
> >> Axel
> >>
> >>
> >> PS: the serverside (axis1) code to get the auth parameter is:
> >> String username = MessageContext.getCurrentContext().getUsername();
> >
> > --
> > J. Daniel Kulp
> > Principal Engineer
> > IONA
> > P: 781-902-8727    C: 508-380-7194
> > daniel.kulp@iona.com
> > http://www.dankulp.com/blog

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Axel Becker <ax...@becker-coding.de>.
Hi Dan,

this doenst work too :-(

following the trace from tcpmon:

POST /GDHSService/services/INFOService HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.5.0_11
Host: localhost:9090
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Transfer-Encoding: chunked

18c
<soap:Envelope mlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <ns2:getCompanies 
    xmlns="http://xml.apache.org/xml-soap"
    xmlns:ns2="http://webservices.impl.service.prj.beckercoding.de"
    xmlns:ns3="http://bean.transfer.services.beckercoding.de"
    xmlns:ns4="http://127.0.0.1:9090/GDHSService/services/INFOService">
    <ns2:gmId>1</ns2:gmId>
   </ns2:getCompanies>
  </soap:Body>
</soap:Envelope>
0


Thanks for your help
Axel




dkulp wrote:
> 
> 
> Alex,
> 
> Could you try the JAX-WS standard way of setting the username/password?
> 
> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>                 SERVICE_NAME);
> INFOService port = ss.getINFOService();
> BindingProvider bp = (BindingProvider)port;
> bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "BJ");
> bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
> 
> 
> Dan
> 
> 
> On Wednesday 25 July 2007 17:27, Axel Becker wrote:
>> Hi,
>>
>> i generated the client code with the wsdl2java from an existing wsdl.
>>
>> now i want to connect to this service (it is an axis 1 webservice).
>> the service ist protected with a http basic authentication. i use the
>> following code, but it doesnt work :-(
>>
>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>> SERVICE_NAME);
>>
>> Client client = ClientProxy.getClient(ss.getINFOService());
>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>
>> httpConduit.getAuthorization().setUserName("username1");
>> httpConduit.getProxyAuthorization().setUserName("username1");
>>
>> INFOService service = ss.getINFOService();
>> //do somthing with service
>>
>> Where is the mistake?
>>
>> Thanks for your help!
>> Axel
>>
>>
>> PS: the serverside (axis1) code to get the auth parameter is:
>> String username = MessageContext.getCurrentContext().getUsername();
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11806102
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Daniel Kulp <dk...@apache.org>.
Alex,

Could you try the JAX-WS standard way of setting the username/password?

INFOServiceService ss = new INFOServiceService(SERVICE_URL,
                SERVICE_NAME);
INFOService port = ss.getINFOService();
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "BJ");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");


Dan


On Wednesday 25 July 2007 17:27, Axel Becker wrote:
> Hi,
>
> i generated the client code with the wsdl2java from an existing wsdl.
>
> now i want to connect to this service (it is an axis 1 webservice).
> the service ist protected with a http basic authentication. i use the
> following code, but it doesnt work :-(
>
> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> SERVICE_NAME);
>
> Client client = ClientProxy.getClient(ss.getINFOService());
> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>
> httpConduit.getAuthorization().setUserName("username1");
> httpConduit.getProxyAuthorization().setUserName("username1");
>
> INFOService service = ss.getINFOService();
> //do somthing with service
>
> Where is the mistake?
>
> Thanks for your help!
> Axel
>
>
> PS: the serverside (axis1) code to get the auth parameter is:
> String username = MessageContext.getCurrentContext().getUsername();

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by petrica <pe...@cluemail.com>.

Hello to all,

I have a similar problem with a generated client ( it's included in mtom
samples from Apache CXF 2.0 distribution) when I am behind of the corporate
firewall. I can't pass the proxy server and I have the error : "Server
returned HTTP response code: 407 for URL ... "

        TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
        TestMtom port = (TestMtom) tms.getPort(PORT_NAME, TestMtom.class);
        Binding binding = ((BindingProvider)port).getBinding();
        ((SOAPBinding)binding).setMTOMEnabled(true);

        Client clt = ClientProxy.getClient(port);

and I tried many posibilities included the code like Alex.

More , a created a cxf.xml file that is loaded (it seems) by method call <<
new TestMtomService(wsdlURL, SERVICE_NAME) >>. I let these settings in it :

  <http-conf:conduit
name="{http://cxf.apache.org/mime}TestMtomPort.http-conduit">

    <http-conf:client Connection="Keep-Alive"
                      MaxRetransmits="1"
                      AllowChunking="false" 
					  ProxyServer="1.1.1.1"
					  ProxyServerPort="2222" />
    <http-conf:basicAuthSupplier class="demo.mtom.client.ClientAuthent"/>	
	<http-conf:authorization />
	<http-conf:proxyAuthorization />

  </http-conf:conduit>

Also I created a class named ClientAuthent which extends
HttpBasicAuthSupplier and override getPreemptiveUserPass 
    public UserPass getPreemptiveUserPass(
            String  conduitName,
            URL     currentURL,
            Message message) 
    {
    	return  createUserPass( "myuser" ,"mypassword");
    } 


I don't know what other settings have to do for reading all informations for
ProxyServer, ProxyPort, ProxyUser and ProxyPassword.
Also, I didn't find out others attributes for <http-conf:authorization />
and <http-conf:proxyAuthorization />.

Maybe this will solve the problem.

Can somebody help me ?

Thank in advance for help,
Petrica
==================================================================

Willem Jiang-2 wrote:
> 
> Hi Axel,
> 
> I checked the HTTPConduit code, your way to set the http basic 
> authentication is right.
> 
> Can you use tcpmon to check the authentication informantion has been set 
> into the http headers?
> 
> If not, I think it must be the CXF's bug.
> 
> 
> Willem.
> 
> Axel Becker wrote:
>> Hi,
>>
>> i generated the client code with the wsdl2java from an existing wsdl.
>>
>> now i want to connect to this service (it is an axis 1 webservice). the
>> service ist protected with a http basic authentication. i use the
>> following
>> code, but it doesnt work :-(
>>
>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>> SERVICE_NAME);
>>
>> Client client = ClientProxy.getClient(ss.getINFOService());
>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>> 			
>> httpConduit.getAuthorization().setUserName("username1");
>> httpConduit.getProxyAuthorization().setUserName("username1");
>> 			
>> INFOService service = ss.getINFOService();
>> //do somthing with service
>>
>> Where is the mistake?
>>
>> Thanks for your help!
>> Axel
>>
>>
>> PS: the serverside (axis1) code to get the auth parameter is:
>> String username = MessageContext.getCurrentContext().getUsername();
>>
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11968274
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by gdprao <gd...@yahoo.com>.
Hi Dan,

Thanks for digging into the problem.  I have tried your suggestion. I have
dowloaded the WSDL and supplied WSDL file path instead of http URL to the
client and invoked the service, it worked fine and authentication was
successful. But  you mean the client should be allowed to dowload the WSDL
without authentication and then at the time of invocation should it enforce
authentication?  If that is the case, I would like to know as to how can I
configure basic authentication for the CXF web service.  I have the
following Basic authentication configured for the /services/* url-pattern in
my web.xml as follows:


	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<display-name>CXF Servlet</display-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/services/*</url-pattern>
	</servlet-mapping>

	<security-constraint>
		<web-resource-collection>
			<web-resource-name>AllServices</web-resource-name>
			<url-pattern>/services/*</url-pattern>
		</web-resource-collection>
		<auth-constraint>
			<role-name>admin</role-name>
		</auth-constraint>
	</security-constraint>
	<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>ProtectedArea</realm-name>
	</login-config>
	<security-role>
		<role-name>admin</role-name>
	</security-role>

Thanks,
Durga


dkulp wrote:
> 
> 
> Hmmm....  this is for the WSDL.    I'm not sure if the code for grabbing 
> the wsdl via HTTP works with the Auth stuff yet.  (I'm pretty sure it 
> doesn't actually now that I think about it)
> 
> Can you download the wsdl manually an point the client at the downloaded 
> wsdl and see if it can communicate?    
> 
> My gut feeling says the invoke communication will work, but the wsdl get 
> stuff won't.  
> 
> Dan
> 
> On Thursday 02 August 2007 15:07, gdprao wrote:
>> Hi,
>>
>> Thanks for the reply.  Please see my following client code and TCP
>> monitor logs.
>>
>> Client Code:
>> ------------
>> SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
>>         Greeter port = ss.getSoapPort();
>> //HTTP authentication code
>>         BindingProvider bp = (BindingProvider)port;
>>        
>> //bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
>> "admin");
>>        
>> //bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
>> "admin");
>>         AuthorizationPolicy authzPolicy =
>>             new AuthorizationPolicy();
>>         authzPolicy.setUserName("admin");
>>         authzPolicy.setPassword("admin");
>>         bp.getRequestContext().put(
>>             AuthorizationPolicy.class.getName(),
>>             authzPolicy
>>         );
>>
>>         System.out.println("Invoking sayHi...");
>>         java.lang.String _sayHi_string = port.sayHi();
>>         System.out.println("Message from service: "+_sayHi_string);
>>
>>
>> applicationContext-cxf.xml:
>> --------------------------
>>
>> <bean id="authWebService"
>> 		class="org.apache.hello_world_soap_http.GreeterImpl">
>> 	</bean>
>>
>> 	<jaxws:endpoint id="authService" implementor="#authWebService"
>> 		address="/GreeterService"/>
>>
>>
>> Request Headers:
>> ----------------
>>
>> GET /authtest/services/GreeterService?wsdl HTTP/1.1
>> User-Agent: Java/1.5.0_11
>> Host: localhost:8080
>> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>> Connection: keep-alive
>>
>> Response Headers:
>> ------------------
>>
>> HTTP/1.1 401 Unauthorized
>> Server: Apache-Coyote/1.1
>> Pragma: No-cache
>> Cache-Control: no-cache
>> Expires: Wed, 31 Dec 1969 16:00:00 PST
>> WWW-Authenticate: Basic realm="ProtectedArea"
>> Content-Type: text/html;charset=utf-8
>> Content-Length: 954
>> Date: Thu, 02 Aug 2007 18:53:19 GMT
>>
>> Howerver when I tried the same web service using REST url from the
>> browser, it was successful.
>>
>> http://localhost:8080/authtest/services/GreeterService/sayHi
>>
>> The request headers in tcpmon is as follows:
>>
>> GET /authtest/services/GreeterService/sayHi HTTP/1.1
>> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
>> application/x-shockwave-flash, application/vnd.ms-excel,
>> application/vnd.ms-powerpoint, application/msword,
>> application/xaml+xml, application/vnd.ms-xpsdocument,
>> application/x-ms-xbap,
>> application/x-ms-application, */*
>> Accept-Language: en-us
>> UA-CPU: x86
>> Accept-Encoding: gzip, deflate
>> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64;
>> SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR
>> 3.0.04506.30) Host: localhost:8080
>> Connection: Keep-Alive
>> Authorization: Basic YWRtaW46YWRtaW4=
>>
>> Appreciate for the help.
>>
>> Thanks,
>> Durga
>>
>> Willem Jiang-2 wrote:
>> > Can you elaborate the configuration of the CXF web service?
>> > Again,:
>> > Can you use tcpmon[1] to check the authentication informantion has
>> > been set
>> > into the http headers?
>> >
>> > [1] https://tcpmon.dev.java.net/
>> >
>> > Willem.
>> >
>> > gdprao wrote:
>> >> Hi,
>> >>
>> >> I have tried all the options mentioned for the CXF client on this
>> >> thread with username and password to invoke a CXF web service which
>> >> is set up with
>> >> HTTP basic authentication.  I am getting HTTP 401K status code. I
>> >> am using
>> >> CXF 2.0 release version. Can someone shed light on this.
>> >>
>> >> Thanks,
>> >> Durga
>> >>
>> >> Axel Becker wrote:
>> >>> Hi Willem,
>> >>>
>> >>> it follows a log file snip that i created with the tomcat request
>> >>> dumper valve. nearly at the end you can see that the authType is
>> >>> null
>> >>>
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI
>> >>> =/GDHSService/services/INFOService
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> authType=null
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> characterEncoding=UTF-8
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> contentLength=-1
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> contentType=text/xml; charset=UTF-8
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> contextPath=/GDHSService
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=content-type=text/xml; charset=UTF-8
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=soapaction=""
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=cache-control=no-cache
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=pragma=no-cache
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=user-agent=Java/1.5.0_11
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=host=localhost:8080
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=connection=keep-alive
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> header=transfer-encoding=chunked
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> locale=de_DE
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> method=POST
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> pathInfo=/INFOService
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> protocol=HTTP/1.1
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> queryString=null
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> remoteAddr=127.0.0.1
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> remoteHost=127.0.0.1
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> remoteUser=null
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> requestedSessionId=null
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> scheme=http
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> serverName=localhost
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> serverPort=8080
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> servletPath=/services
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> isSecure=false
>> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> >>> ---------------------------------------------------------------
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> ---------------------------------------------------------------
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> authType=null
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> contentLength=-1
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> contentType=text/xml;charset=utf-8
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> header=Content-Type=text/xml;charset=utf-8
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> header=Transfer-Encoding=chunked
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> header=Date=Wed, 25 Jul 2007 17:19:59 GMT
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> header=Server=Apache-Coyote/1.1
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> header=Connection=close
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> message=null
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> remoteUser=null
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> status=500
>> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> >>> ===============================================================
>> >>>
>> >>> thanks for your help
>> >>> Axel
>> >>>
>> >>> Willem Jiang-2 wrote:
>> >>>> Hi Axel,
>> >>>>
>> >>>> I checked the HTTPConduit code, your way to set the http basic
>> >>>> authentication is right.
>> >>>>
>> >>>> Can you use tcpmon to check the authentication informantion has
>> >>>> been set
>> >>>> into the http headers?
>> >>>>
>> >>>> If not, I think it must be the CXF's bug.
>> >>>>
>> >>>>
>> >>>> Willem.
>> >>>>
>> >>>> Axel Becker wrote:
>> >>>>> Hi,
>> >>>>>
>> >>>>> i generated the client code with the wsdl2java from an existing
>> >>>>> wsdl.
>> >>>>>
>> >>>>> now i want to connect to this service (it is an axis 1
>> >>>>> webservice). the
>> >>>>> service ist protected with a http basic authentication. i use
>> >>>>> the following
>> >>>>> code, but it doesnt work :-(
>> >>>>>
>> >>>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>> >>>>> SERVICE_NAME);
>> >>>>>
>> >>>>> Client client = ClientProxy.getClient(ss.getINFOService());
>> >>>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>> >>>>>
>> >>>>> httpConduit.getAuthorization().setUserName("username1");
>> >>>>> httpConduit.getProxyAuthorization().setUserName("username1");
>> >>>>>
>> >>>>> INFOService service = ss.getINFOService();
>> >>>>> //do somthing with service
>> >>>>>
>> >>>>> Where is the mistake?
>> >>>>>
>> >>>>> Thanks for your help!
>> >>>>> Axel
>> >>>>>
>> >>>>>
>> >>>>> PS: the serverside (axis1) code to get the auth parameter is:
>> >>>>> String username =
>> >>>>> MessageContext.getCurrentContext().getUsername();
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11971969
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Daniel Kulp <dk...@apache.org>.
Hmmm....  this is for the WSDL.    I'm not sure if the code for grabbing 
the wsdl via HTTP works with the Auth stuff yet.  (I'm pretty sure it 
doesn't actually now that I think about it)

Can you download the wsdl manually an point the client at the downloaded 
wsdl and see if it can communicate?    

My gut feeling says the invoke communication will work, but the wsdl get 
stuff won't.  

Dan

On Thursday 02 August 2007 15:07, gdprao wrote:
> Hi,
>
> Thanks for the reply.  Please see my following client code and TCP
> monitor logs.
>
> Client Code:
> ------------
> SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
>         Greeter port = ss.getSoapPort();
> //HTTP authentication code
>         BindingProvider bp = (BindingProvider)port;
>        
> //bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
> "admin");
>        
> //bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
> "admin");
>         AuthorizationPolicy authzPolicy =
>             new AuthorizationPolicy();
>         authzPolicy.setUserName("admin");
>         authzPolicy.setPassword("admin");
>         bp.getRequestContext().put(
>             AuthorizationPolicy.class.getName(),
>             authzPolicy
>         );
>
>         System.out.println("Invoking sayHi...");
>         java.lang.String _sayHi_string = port.sayHi();
>         System.out.println("Message from service: "+_sayHi_string);
>
>
> applicationContext-cxf.xml:
> --------------------------
>
> <bean id="authWebService"
> 		class="org.apache.hello_world_soap_http.GreeterImpl">
> 	</bean>
>
> 	<jaxws:endpoint id="authService" implementor="#authWebService"
> 		address="/GreeterService"/>
>
>
> Request Headers:
> ----------------
>
> GET /authtest/services/GreeterService?wsdl HTTP/1.1
> User-Agent: Java/1.5.0_11
> Host: localhost:8080
> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> Connection: keep-alive
>
> Response Headers:
> ------------------
>
> HTTP/1.1 401 Unauthorized
> Server: Apache-Coyote/1.1
> Pragma: No-cache
> Cache-Control: no-cache
> Expires: Wed, 31 Dec 1969 16:00:00 PST
> WWW-Authenticate: Basic realm="ProtectedArea"
> Content-Type: text/html;charset=utf-8
> Content-Length: 954
> Date: Thu, 02 Aug 2007 18:53:19 GMT
>
> Howerver when I tried the same web service using REST url from the
> browser, it was successful.
>
> http://localhost:8080/authtest/services/GreeterService/sayHi
>
> The request headers in tcpmon is as follows:
>
> GET /authtest/services/GreeterService/sayHi HTTP/1.1
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> application/x-shockwave-flash, application/vnd.ms-excel,
> application/vnd.ms-powerpoint, application/msword,
> application/xaml+xml, application/vnd.ms-xpsdocument,
> application/x-ms-xbap,
> application/x-ms-application, */*
> Accept-Language: en-us
> UA-CPU: x86
> Accept-Encoding: gzip, deflate
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64;
> SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR
> 3.0.04506.30) Host: localhost:8080
> Connection: Keep-Alive
> Authorization: Basic YWRtaW46YWRtaW4=
>
> Appreciate for the help.
>
> Thanks,
> Durga
>
> Willem Jiang-2 wrote:
> > Can you elaborate the configuration of the CXF web service?
> > Again,:
> > Can you use tcpmon[1] to check the authentication informantion has
> > been set
> > into the http headers?
> >
> > [1] https://tcpmon.dev.java.net/
> >
> > Willem.
> >
> > gdprao wrote:
> >> Hi,
> >>
> >> I have tried all the options mentioned for the CXF client on this
> >> thread with username and password to invoke a CXF web service which
> >> is set up with
> >> HTTP basic authentication.  I am getting HTTP 401K status code. I
> >> am using
> >> CXF 2.0 release version. Can someone shed light on this.
> >>
> >> Thanks,
> >> Durga
> >>
> >> Axel Becker wrote:
> >>> Hi Willem,
> >>>
> >>> it follows a log file snip that i created with the tomcat request
> >>> dumper valve. nearly at the end you can see that the authType is
> >>> null
> >>>
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI
> >>> =/GDHSService/services/INFOService
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> authType=null
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> characterEncoding=UTF-8
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> contentLength=-1
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> contentType=text/xml; charset=UTF-8
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> contextPath=/GDHSService
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=content-type=text/xml; charset=UTF-8
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=soapaction=""
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=cache-control=no-cache
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=pragma=no-cache
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=user-agent=Java/1.5.0_11
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=host=localhost:8080
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=connection=keep-alive
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> header=transfer-encoding=chunked
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> locale=de_DE
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> method=POST
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> pathInfo=/INFOService
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> protocol=HTTP/1.1
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> queryString=null
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> remoteAddr=127.0.0.1
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> remoteHost=127.0.0.1
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> remoteUser=null
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> requestedSessionId=null
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> scheme=http
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> serverName=localhost
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> serverPort=8080
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> servletPath=/services
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> isSecure=false
> >>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> >>> ---------------------------------------------------------------
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> ---------------------------------------------------------------
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> authType=null
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> contentLength=-1
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> contentType=text/xml;charset=utf-8
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> header=Content-Type=text/xml;charset=utf-8
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> header=Transfer-Encoding=chunked
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> header=Date=Wed, 25 Jul 2007 17:19:59 GMT
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> header=Server=Apache-Coyote/1.1
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> header=Connection=close
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> message=null
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> remoteUser=null
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> status=500
> >>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> >>> ===============================================================
> >>>
> >>> thanks for your help
> >>> Axel
> >>>
> >>> Willem Jiang-2 wrote:
> >>>> Hi Axel,
> >>>>
> >>>> I checked the HTTPConduit code, your way to set the http basic
> >>>> authentication is right.
> >>>>
> >>>> Can you use tcpmon to check the authentication informantion has
> >>>> been set
> >>>> into the http headers?
> >>>>
> >>>> If not, I think it must be the CXF's bug.
> >>>>
> >>>>
> >>>> Willem.
> >>>>
> >>>> Axel Becker wrote:
> >>>>> Hi,
> >>>>>
> >>>>> i generated the client code with the wsdl2java from an existing
> >>>>> wsdl.
> >>>>>
> >>>>> now i want to connect to this service (it is an axis 1
> >>>>> webservice). the
> >>>>> service ist protected with a http basic authentication. i use
> >>>>> the following
> >>>>> code, but it doesnt work :-(
> >>>>>
> >>>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
> >>>>> SERVICE_NAME);
> >>>>>
> >>>>> Client client = ClientProxy.getClient(ss.getINFOService());
> >>>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> >>>>>
> >>>>> httpConduit.getAuthorization().setUserName("username1");
> >>>>> httpConduit.getProxyAuthorization().setUserName("username1");
> >>>>>
> >>>>> INFOService service = ss.getINFOService();
> >>>>> //do somthing with service
> >>>>>
> >>>>> Where is the mistake?
> >>>>>
> >>>>> Thanks for your help!
> >>>>> Axel
> >>>>>
> >>>>>
> >>>>> PS: the serverside (axis1) code to get the auth parameter is:
> >>>>> String username =
> >>>>> MessageContext.getCurrentContext().getUsername();

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by gdprao <gd...@yahoo.com>.
Hi,

Thanks for the reply.  Please see my following client code and TCP monitor
logs.

Client Code:
------------
SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
        Greeter port = ss.getSoapPort();  
//HTTP authentication code
        BindingProvider bp = (BindingProvider)port; 
        //bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"admin"); 
        //bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"admin"); 
        AuthorizationPolicy authzPolicy = 
            new AuthorizationPolicy(); 
        authzPolicy.setUserName("admin"); 
        authzPolicy.setPassword("admin"); 
        bp.getRequestContext().put( 
            AuthorizationPolicy.class.getName(), 
            authzPolicy 
        ); 
        
        System.out.println("Invoking sayHi...");
        java.lang.String _sayHi_string = port.sayHi();
        System.out.println("Message from service: "+_sayHi_string);


applicationContext-cxf.xml:
--------------------------

<bean id="authWebService"
		class="org.apache.hello_world_soap_http.GreeterImpl">
	</bean>
	
	<jaxws:endpoint id="authService" implementor="#authWebService"
		address="/GreeterService"/>


Request Headers:
----------------

GET /authtest/services/GreeterService?wsdl HTTP/1.1
User-Agent: Java/1.5.0_11
Host: localhost:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

Response Headers:
------------------

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Wed, 31 Dec 1969 16:00:00 PST
WWW-Authenticate: Basic realm="ProtectedArea"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: Thu, 02 Aug 2007 18:53:19 GMT

Howerver when I tried the same web service using REST url from the browser,
it was successful.

http://localhost:8080/authtest/services/GreeterService/sayHi

The request headers in tcpmon is as follows:

GET /authtest/services/GreeterService/sayHi HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, application/xaml+xml,
application/vnd.ms-xpsdocument, application/x-ms-xbap,
application/x-ms-application, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64; SV1;
.NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30)
Host: localhost:8080
Connection: Keep-Alive
Authorization: Basic YWRtaW46YWRtaW4=

Appreciate for the help.

Thanks,
Durga




Willem Jiang-2 wrote:
> 
> Can you elaborate the configuration of the CXF web service?
> Again,:
> Can you use tcpmon[1] to check the authentication informantion has been
> set
> into the http headers?
> 
> [1] https://tcpmon.dev.java.net/
> 
> Willem.
> 
> 
> gdprao wrote:
>> Hi,
>>
>> I have tried all the options mentioned for the CXF client on this thread
>> with username and password to invoke a CXF web service which is set up
>> with
>> HTTP basic authentication.  I am getting HTTP 401K status code. I am
>> using
>> CXF 2.0 release version. Can someone shed light on this. 
>>
>> Thanks,
>> Durga
>>
>>
>>
>> Axel Becker wrote:
>>   
>>> Hi Willem,
>>>
>>> it follows a log file snip that i created with the tomcat request dumper
>>> valve. nearly at the end you can see that the authType is null
>>>
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI      
>>> =/GDHSService/services/INFOService
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>>> authType=null
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: 
>>> characterEncoding=UTF-8
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:     
>>> contentLength=-1
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>>> contentType=text/xml; charset=UTF-8
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>>> contextPath=/GDHSService
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=content-type=text/xml; charset=UTF-8
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=soapaction=""
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=cache-control=no-cache
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=pragma=no-cache
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=user-agent=Java/1.5.0_11
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=host=localhost:8080
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=connection=keep-alive
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> header=transfer-encoding=chunked
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> locale=de_DE
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> method=POST
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>>> pathInfo=/INFOService
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>>> protocol=HTTP/1.1
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>>> queryString=null
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>>> remoteAddr=127.0.0.1
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>>> remoteHost=127.0.0.1
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>>> remoteUser=null
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>>> requestedSessionId=null
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>>> scheme=http
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>>> serverName=localhost
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>>> serverPort=8080
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>>> servletPath=/services
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>>> isSecure=false
>>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>>> ---------------------------------------------------------------
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>>> ---------------------------------------------------------------
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:          
>>> authType=null
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:     
>>> contentLength=-1
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:       
>>> contentType=text/xml;charset=utf-8
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> header=Content-Type=text/xml;charset=utf-8
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> header=Transfer-Encoding=chunked
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> header=Date=Wed, 25 Jul 2007 17:19:59 GMT
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> header=Server=Apache-Coyote/1.1
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> header=Connection=close
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:           
>>> message=null
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:        
>>> remoteUser=null
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>>> status=500
>>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>>> ===============================================================
>>>
>>> thanks for your help
>>> Axel
>>>
>>>
>>>
>>> Willem Jiang-2 wrote:
>>>     
>>>> Hi Axel,
>>>>
>>>> I checked the HTTPConduit code, your way to set the http basic 
>>>> authentication is right.
>>>>
>>>> Can you use tcpmon to check the authentication informantion has been
>>>> set 
>>>> into the http headers?
>>>>
>>>> If not, I think it must be the CXF's bug.
>>>>
>>>>
>>>> Willem.
>>>>
>>>> Axel Becker wrote:
>>>>       
>>>>> Hi,
>>>>>
>>>>> i generated the client code with the wsdl2java from an existing wsdl.
>>>>>
>>>>> now i want to connect to this service (it is an axis 1 webservice).
>>>>> the
>>>>> service ist protected with a http basic authentication. i use the
>>>>> following
>>>>> code, but it doesnt work :-(
>>>>>
>>>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>>>>> SERVICE_NAME);
>>>>>
>>>>> Client client = ClientProxy.getClient(ss.getINFOService());
>>>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>>>> 			
>>>>> httpConduit.getAuthorization().setUserName("username1");
>>>>> httpConduit.getProxyAuthorization().setUserName("username1");
>>>>> 			
>>>>> INFOService service = ss.getINFOService();
>>>>> //do somthing with service
>>>>>
>>>>> Where is the mistake?
>>>>>
>>>>> Thanks for your help!
>>>>> Axel
>>>>>
>>>>>
>>>>> PS: the serverside (axis1) code to get the auth parameter is:
>>>>> String username = MessageContext.getCurrentContext().getUsername();
>>>>>
>>>>>
>>>>>   
>>>>>         
>>>>       
>>>     
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11970290
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Willem Jiang <ni...@iona.com>.
Can you elaborate the configuration of the CXF web service?
Again,:
Can you use tcpmon[1] to check the authentication informantion has been set
into the http headers?

[1] https://tcpmon.dev.java.net/

Willem.


gdprao wrote:
> Hi,
>
> I have tried all the options mentioned for the CXF client on this thread
> with username and password to invoke a CXF web service which is set up with
> HTTP basic authentication.  I am getting HTTP 401K status code. I am using
> CXF 2.0 release version. Can someone shed light on this. 
>
> Thanks,
> Durga
>
>
>
> Axel Becker wrote:
>   
>> Hi Willem,
>>
>> it follows a log file snip that i created with the tomcat request dumper
>> valve. nearly at the end you can see that the authType is null
>>
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI      
>> =/GDHSService/services/INFOService
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>> authType=null
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: 
>> characterEncoding=UTF-8
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:     
>> contentLength=-1
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>> contentType=text/xml; charset=UTF-8
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>> contextPath=/GDHSService
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=content-type=text/xml; charset=UTF-8
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=soapaction=""
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=cache-control=no-cache
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=pragma=no-cache
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=user-agent=Java/1.5.0_11
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=host=localhost:8080
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=connection=keep-alive
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> header=transfer-encoding=chunked
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> locale=de_DE
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> method=POST
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>> pathInfo=/INFOService
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>> protocol=HTTP/1.1
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>> queryString=null
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>> remoteAddr=127.0.0.1
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>> remoteHost=127.0.0.1
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>> remoteUser=null
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> requestedSessionId=null
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
>> scheme=http
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>> serverName=localhost
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
>> serverPort=8080
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
>> servletPath=/services
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
>> isSecure=false
>> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
>> ---------------------------------------------------------------
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> ---------------------------------------------------------------
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:          
>> authType=null
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:     
>> contentLength=-1
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:       
>> contentType=text/xml;charset=utf-8
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> header=Content-Type=text/xml;charset=utf-8
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> header=Transfer-Encoding=chunked
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> header=Date=Wed, 25 Jul 2007 17:19:59 GMT
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> header=Server=Apache-Coyote/1.1
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> header=Connection=close
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:           
>> message=null
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:        
>> remoteUser=null
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
>> status=500
>> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
>> ===============================================================
>>
>> thanks for your help
>> Axel
>>
>>
>>
>> Willem Jiang-2 wrote:
>>     
>>> Hi Axel,
>>>
>>> I checked the HTTPConduit code, your way to set the http basic 
>>> authentication is right.
>>>
>>> Can you use tcpmon to check the authentication informantion has been set 
>>> into the http headers?
>>>
>>> If not, I think it must be the CXF's bug.
>>>
>>>
>>> Willem.
>>>
>>> Axel Becker wrote:
>>>       
>>>> Hi,
>>>>
>>>> i generated the client code with the wsdl2java from an existing wsdl.
>>>>
>>>> now i want to connect to this service (it is an axis 1 webservice). the
>>>> service ist protected with a http basic authentication. i use the
>>>> following
>>>> code, but it doesnt work :-(
>>>>
>>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>>>> SERVICE_NAME);
>>>>
>>>> Client client = ClientProxy.getClient(ss.getINFOService());
>>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>>> 			
>>>> httpConduit.getAuthorization().setUserName("username1");
>>>> httpConduit.getProxyAuthorization().setUserName("username1");
>>>> 			
>>>> INFOService service = ss.getINFOService();
>>>> //do somthing with service
>>>>
>>>> Where is the mistake?
>>>>
>>>> Thanks for your help!
>>>> Axel
>>>>
>>>>
>>>> PS: the serverside (axis1) code to get the auth parameter is:
>>>> String username = MessageContext.getCurrentContext().getUsername();
>>>>
>>>>
>>>>   
>>>>         
>>>       
>>     
>
>   

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by gdprao <gd...@yahoo.com>.
Hi,

I have tried all the options mentioned for the CXF client on this thread
with username and password to invoke a CXF web service which is set up with
HTTP basic authentication.  I am getting HTTP 401K status code. I am using
CXF 2.0 release version. Can someone shed light on this. 

Thanks,
Durga



Axel Becker wrote:
> 
> Hi Willem,
> 
> it follows a log file snip that i created with the tomcat request dumper
> valve. nearly at the end you can see that the authType is null
> 
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI      
> =/GDHSService/services/INFOService
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
> authType=null
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: 
> characterEncoding=UTF-8
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:     
> contentLength=-1
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
> contentType=text/xml; charset=UTF-8
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
> contextPath=/GDHSService
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=content-type=text/xml; charset=UTF-8
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=soapaction=""
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=cache-control=no-cache
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=pragma=no-cache
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=user-agent=Java/1.5.0_11
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=host=localhost:8080
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=connection=keep-alive
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> header=transfer-encoding=chunked
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> locale=de_DE
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> method=POST
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
> pathInfo=/INFOService
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
> protocol=HTTP/1.1
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
> queryString=null
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
> remoteAddr=127.0.0.1
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
> remoteHost=127.0.0.1
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
> remoteUser=null
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> requestedSessionId=null
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
> scheme=http
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
> serverName=localhost
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
> serverPort=8080
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
> servletPath=/services
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
> isSecure=false
> 2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
> ---------------------------------------------------------------
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> ---------------------------------------------------------------
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:          
> authType=null
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:     
> contentLength=-1
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:       
> contentType=text/xml;charset=utf-8
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> header=Content-Type=text/xml;charset=utf-8
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> header=Transfer-Encoding=chunked
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> header=Date=Wed, 25 Jul 2007 17:19:59 GMT
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> header=Server=Apache-Coyote/1.1
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> header=Connection=close
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:           
> message=null
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:        
> remoteUser=null
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
> status=500
> 2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
> ===============================================================
> 
> thanks for your help
> Axel
> 
> 
> 
> Willem Jiang-2 wrote:
>> 
>> Hi Axel,
>> 
>> I checked the HTTPConduit code, your way to set the http basic 
>> authentication is right.
>> 
>> Can you use tcpmon to check the authentication informantion has been set 
>> into the http headers?
>> 
>> If not, I think it must be the CXF's bug.
>> 
>> 
>> Willem.
>> 
>> Axel Becker wrote:
>>> Hi,
>>>
>>> i generated the client code with the wsdl2java from an existing wsdl.
>>>
>>> now i want to connect to this service (it is an axis 1 webservice). the
>>> service ist protected with a http basic authentication. i use the
>>> following
>>> code, but it doesnt work :-(
>>>
>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>>> SERVICE_NAME);
>>>
>>> Client client = ClientProxy.getClient(ss.getINFOService());
>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>> 			
>>> httpConduit.getAuthorization().setUserName("username1");
>>> httpConduit.getProxyAuthorization().setUserName("username1");
>>> 			
>>> INFOService service = ss.getINFOService();
>>> //do somthing with service
>>>
>>> Where is the mistake?
>>>
>>> Thanks for your help!
>>> Axel
>>>
>>>
>>> PS: the serverside (axis1) code to get the auth parameter is:
>>> String username = MessageContext.getCurrentContext().getUsername();
>>>
>>>
>>>   
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11957107
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Axel Becker <ax...@becker-coding.de>.
Hi Willem,

it follows a log file snip that i created with the tomcat request dumper
valve. nearly at the end you can see that the authType is null

2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: REQUEST URI      
=/GDHSService/services/INFOService
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
authType=null
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]: 
characterEncoding=UTF-8
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:      contentLength=-1
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
contentType=text/xml; charset=UTF-8
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
contextPath=/GDHSService
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=content-type=text/xml; charset=UTF-8
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=soapaction=""
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=cache-control=no-cache
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=pragma=no-cache
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=user-agent=Java/1.5.0_11
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=host=localhost:8080
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=connection=keep-alive
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
header=transfer-encoding=chunked
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
locale=de_DE
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
method=POST
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
pathInfo=/INFOService
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
protocol=HTTP/1.1
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
queryString=null
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
remoteAddr=127.0.0.1
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
remoteHost=127.0.0.1
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
remoteUser=null
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
requestedSessionId=null
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:            
scheme=http
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
serverName=localhost
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:        
serverPort=8080
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:       
servletPath=/services
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:          
isSecure=false
2007-07-25 19:19:54 RequestDumperValve[/GDHSService]:
---------------------------------------------------------------
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
---------------------------------------------------------------
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:          
authType=null
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:      contentLength=-1
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:       
contentType=text/xml;charset=utf-8
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
header=Content-Type=text/xml;charset=utf-8
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
header=Transfer-Encoding=chunked
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
header=Date=Wed, 25 Jul 2007 17:19:59 GMT
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
header=Server=Apache-Coyote/1.1
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:            
header=Connection=close
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:           
message=null
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:        
remoteUser=null
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:             status=500
2007-07-25 19:19:59 RequestDumperValve[/GDHSService]:
===============================================================

thanks for your help
Axel



Willem Jiang-2 wrote:
> 
> Hi Axel,
> 
> I checked the HTTPConduit code, your way to set the http basic 
> authentication is right.
> 
> Can you use tcpmon to check the authentication informantion has been set 
> into the http headers?
> 
> If not, I think it must be the CXF's bug.
> 
> 
> Willem.
> 
> Axel Becker wrote:
>> Hi,
>>
>> i generated the client code with the wsdl2java from an existing wsdl.
>>
>> now i want to connect to this service (it is an axis 1 webservice). the
>> service ist protected with a http basic authentication. i use the
>> following
>> code, but it doesnt work :-(
>>
>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>> SERVICE_NAME);
>>
>> Client client = ClientProxy.getClient(ss.getINFOService());
>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>> 			
>> httpConduit.getAuthorization().setUserName("username1");
>> httpConduit.getProxyAuthorization().setUserName("username1");
>> 			
>> INFOService service = ss.getINFOService();
>> //do somthing with service
>>
>> Where is the mistake?
>>
>> Thanks for your help!
>> Axel
>>
>>
>> PS: the serverside (axis1) code to get the auth parameter is:
>> String username = MessageContext.getCurrentContext().getUsername();
>>
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11805691
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by junker66 <gm...@yahoo.com>.

Will this be addressed in a 2.0.5 or 2.1?

g


Willem2 wrote:
> 
> Hi Petrica
> 
> Here is the configuration guide of the HTTP Client [1] 
> http://cwiki.apache.org/CXF20DOC/client-http-transport.html
> Your can set the proxy server , and proxy server port , 
> proxyAuthorization etc
> 
> But current CXF not support to get the wsdl with the http proxy or basic 
> authentication setting,
> because we don't use the http conduit to get the wsdl.
> 
> Willem.
> 
> petrica wrote:
>> Hello to all,
>>
>> I have a similar problem with a generated client ( it's included in mtom
>> samples from Apache CXF 2.0 distribution) when I am behind of the
>> corporate
>> firewall. I can't pass the proxy server and I have the error : "Server
>> returned HTTP response code: 407 for URL ... "
>>
>>         TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
>>         TestMtom port = (TestMtom) tms.getPort(PORT_NAME,
>> TestMtom.class);
>>         Binding binding = ((BindingProvider)port).getBinding();
>>         ((SOAPBinding)binding).setMTOMEnabled(true);
>>
>>         Client clt = ClientProxy.getClient(port);
>>
>> and I tried many posibilities included the code like Alex.
>>
>> More , a created a cxf.xml file that is loaded (it seems) by method call
>> <<
>> new TestMtomService(wsdlURL, SERVICE_NAME) >>. I let these settings in it
>> :
>>
>>   
>>
>>     
>>     	
>> 	
>> 	
>>
>>   
>>
>> Also I created a class named ClientAuthent which extends
>> HttpBasicAuthSupplier and override getPreemptiveUserPass 
>>     public UserPass getPreemptiveUserPass(
>>             String  conduitName,
>>             URL     currentURL,
>>             Message message) 
>>     {
>>     	return  createUserPass( "myuser" ,"mypassword");
>>     } 
>>
>>
>> I don't know what other settings have to do for reading all informations
>> for
>> ProxyServer, ProxyPort, ProxyUser and ProxyPassword.
>> Also, I didn't find out others attributes for  and .
>>
>> Maybe this will solve the problem.
>>
>> Can somebody help me ?
>>
>> Thank in advance for help,
>> Petrica
>> ==================================================================
>>
>> Willem Jiang-2 wrote:
>>   
>>> Hi Axel,
>>>
>>> I checked the HTTPConduit code, your way to set the http basic 
>>> authentication is right.
>>>
>>> Can you use tcpmon to check the authentication informantion has been set 
>>> into the http headers?
>>>
>>> If not, I think it must be the CXF's bug.
>>>
>>>
>>> Willem.
>>>
>>> Axel Becker wrote:
>>>     
>>>> Hi,
>>>>
>>>> i generated the client code with the wsdl2java from an existing wsdl.
>>>>
>>>> now i want to connect to this service (it is an axis 1 webservice). the
>>>> service ist protected with a http basic authentication. i use the
>>>> following
>>>> code, but it doesnt work :-(
>>>>
>>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>>>> SERVICE_NAME);
>>>>
>>>> Client client = ClientProxy.getClient(ss.getINFOService());
>>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>>> 			
>>>> httpConduit.getAuthorization().setUserName("username1");
>>>> httpConduit.getProxyAuthorization().setUserName("username1");
>>>> 			
>>>> INFOService service = ss.getINFOService();
>>>> //do somthing with service
>>>>
>>>> Where is the mistake?
>>>>
>>>> Thanks for your help!
>>>> Axel
>>>>
>>>>
>>>> PS: the serverside (axis1) code to get the auth parameter is:
>>>> String username = MessageContext.getCurrentContext().getUsername();
>>>>
>>>>
>>>>   
>>>>       
>>>     
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tp11800307p15950821.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Willem Jiang <ni...@iona.com>.
Hi Petrica

Here is the configuration guide of the HTTP Client [1] 
http://cwiki.apache.org/CXF20DOC/client-http-transport.html
Your can set the proxy server , and proxy server port , 
proxyAuthorization etc

But current CXF not support to get the wsdl with the http proxy or basic 
authentication setting,
because we don't use the http conduit to get the wsdl.

Willem.

petrica wrote:
> Hello to all,
>
> I have a similar problem with a generated client ( it's included in mtom
> samples from Apache CXF 2.0 distribution) when I am behind of the corporate
> firewall. I can't pass the proxy server and I have the error : "Server
> returned HTTP response code: 407 for URL ... "
>
>         TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
>         TestMtom port = (TestMtom) tms.getPort(PORT_NAME, TestMtom.class);
>         Binding binding = ((BindingProvider)port).getBinding();
>         ((SOAPBinding)binding).setMTOMEnabled(true);
>
>         Client clt = ClientProxy.getClient(port);
>
> and I tried many posibilities included the code like Alex.
>
> More , a created a cxf.xml file that is loaded (it seems) by method call <<
> new TestMtomService(wsdlURL, SERVICE_NAME) >>. I let these settings in it :
>
>   
>
>     
>     	
> 	
> 	
>
>   
>
> Also I created a class named ClientAuthent which extends
> HttpBasicAuthSupplier and override getPreemptiveUserPass 
>     public UserPass getPreemptiveUserPass(
>             String  conduitName,
>             URL     currentURL,
>             Message message) 
>     {
>     	return  createUserPass( "myuser" ,"mypassword");
>     } 
>
>
> I don't know what other settings have to do for reading all informations for
> ProxyServer, ProxyPort, ProxyUser and ProxyPassword.
> Also, I didn't find out others attributes for  and .
>
> Maybe this will solve the problem.
>
> Can somebody help me ?
>
> Thank in advance for help,
> Petrica
> ==================================================================
>
> Willem Jiang-2 wrote:
>   
>> Hi Axel,
>>
>> I checked the HTTPConduit code, your way to set the http basic 
>> authentication is right.
>>
>> Can you use tcpmon to check the authentication informantion has been set 
>> into the http headers?
>>
>> If not, I think it must be the CXF's bug.
>>
>>
>> Willem.
>>
>> Axel Becker wrote:
>>     
>>> Hi,
>>>
>>> i generated the client code with the wsdl2java from an existing wsdl.
>>>
>>> now i want to connect to this service (it is an axis 1 webservice). the
>>> service ist protected with a http basic authentication. i use the
>>> following
>>> code, but it doesnt work :-(
>>>
>>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>>> SERVICE_NAME);
>>>
>>> Client client = ClientProxy.getClient(ss.getINFOService());
>>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>> 			
>>> httpConduit.getAuthorization().setUserName("username1");
>>> httpConduit.getProxyAuthorization().setUserName("username1");
>>> 			
>>> INFOService service = ss.getINFOService();
>>> //do somthing with service
>>>
>>> Where is the mistake?
>>>
>>> Thanks for your help!
>>> Axel
>>>
>>>
>>> PS: the serverside (axis1) code to get the auth parameter is:
>>> String username = MessageContext.getCurrentContext().getUsername();
>>>
>>>
>>>   
>>>       
>>     
>
>   

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by petrica <pe...@cluemail.com>.

Hello to all,

I have a similar problem with a generated client ( it's included in mtom
samples from Apache CXF 2.0 distribution) when I am behind of the corporate
firewall. I can't pass the proxy server and I have the error : "Server
returned HTTP response code: 407 for URL ... "

        TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
        TestMtom port = (TestMtom) tms.getPort(PORT_NAME, TestMtom.class);
        Binding binding = ((BindingProvider)port).getBinding();
        ((SOAPBinding)binding).setMTOMEnabled(true);

        Client clt = ClientProxy.getClient(port);

and I tried many posibilities included the code like Alex.

More , a created a cxf.xml file that is loaded (it seems) by method call <<
new TestMtomService(wsdlURL, SERVICE_NAME) >>. I let these settings in it :

  

    
    	
	
	

  

Also I created a class named ClientAuthent which extends
HttpBasicAuthSupplier and override getPreemptiveUserPass 
    public UserPass getPreemptiveUserPass(
            String  conduitName,
            URL     currentURL,
            Message message) 
    {
    	return  createUserPass( "myuser" ,"mypassword");
    } 


I don't know what other settings have to do for reading all informations for
ProxyServer, ProxyPort, ProxyUser and ProxyPassword.
Also, I didn't find out others attributes for  and .

Maybe this will solve the problem.

Can somebody help me ?

Thank in advance for help,
Petrica
==================================================================

Willem Jiang-2 wrote:
> 
> Hi Axel,
> 
> I checked the HTTPConduit code, your way to set the http basic 
> authentication is right.
> 
> Can you use tcpmon to check the authentication informantion has been set 
> into the http headers?
> 
> If not, I think it must be the CXF's bug.
> 
> 
> Willem.
> 
> Axel Becker wrote:
>> Hi,
>>
>> i generated the client code with the wsdl2java from an existing wsdl.
>>
>> now i want to connect to this service (it is an axis 1 webservice). the
>> service ist protected with a http basic authentication. i use the
>> following
>> code, but it doesnt work :-(
>>
>> INFOServiceService ss = new INFOServiceService(SERVICE_URL,
>> SERVICE_NAME);
>>
>> Client client = ClientProxy.getClient(ss.getINFOService());
>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>> 			
>> httpConduit.getAuthorization().setUserName("username1");
>> httpConduit.getProxyAuthorization().setUserName("username1");
>> 			
>> INFOService service = ss.getINFOService();
>> //do somthing with service
>>
>> Where is the mistake?
>>
>> Thanks for your help!
>> Axel
>>
>>
>> PS: the serverside (axis1) code to get the auth parameter is:
>> String username = MessageContext.getCurrentContext().getUsername();
>>
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-Basic-Auth-with-wsdl2java-generated-Client-tf4148070.html#a11968257
Sent from the cxf-user mailing list archive at Nabble.com.

Re: HTTP Basic Auth with wsdl2java generated Client

Posted by Willem Jiang <ni...@iona.com>.
Hi Axel,

I checked the HTTPConduit code, your way to set the http basic 
authentication is right.

Can you use tcpmon to check the authentication informantion has been set 
into the http headers?

If not, I think it must be the CXF's bug.


Willem.

Axel Becker wrote:
> Hi,
>
> i generated the client code with the wsdl2java from an existing wsdl.
>
> now i want to connect to this service (it is an axis 1 webservice). the
> service ist protected with a http basic authentication. i use the following
> code, but it doesnt work :-(
>
> INFOServiceService ss = new INFOServiceService(SERVICE_URL, SERVICE_NAME);
>
> Client client = ClientProxy.getClient(ss.getINFOService());
> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> 			
> httpConduit.getAuthorization().setUserName("username1");
> httpConduit.getProxyAuthorization().setUserName("username1");
> 			
> INFOService service = ss.getINFOService();
> //do somthing with service
>
> Where is the mistake?
>
> Thanks for your help!
> Axel
>
>
> PS: the serverside (axis1) code to get the auth parameter is:
> String username = MessageContext.getCurrentContext().getUsername();
>
>
>