You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Halewijn Geerts <ha...@enfocus.com> on 2011/06/10 16:18:29 UTC

Proxy authentication

Hi,

I have a client application that connects to a web service through https
using axis2c 1.6.0. If I try to connect through a proxy that requires
authentication, I can¹t connect to the service. If I use a proxy that
doesn¹t require authentication, it works. I used
axis2_svc_client_set_proxy_with_auth to set the proxy.

I set up a squid proxy server and used basic authentication through a custom
written authenticator so I could print what the input was, but nothing gets
printed. I tested the proxy using both Safari and Firefox and everything
works correctly. I also tried to connect to the service via the proxy ( with
authentication ) using the curl command line tool and that also worked
correctly.

I generated client code from the service wsdl file using WSDL2C.

This is the code I use to connect to the service:

...

axutil_error* theError = NULL;
axutil_env_t* theEnvironment = NULL;
axis2_stub_t* theStub = NULL;
axis2_status_t theSetProxyStatus = AXIS2_SUCCESS;

theError = axutil_error_create( axutil_allocator_init( NULL ) );
theEnvironment = axutil_env_create_with_error( axutil_allocator_init( NULL
), theError );

if ( theEnvironment )
{
        theStub = axis2_stub_create_MyService( theEnvironment,
                                           inAxis2cFolder.c_str(),
                                           inMyServiceAddress.c_str() );

    if ( theStub  )
    {
        if ( ! inHost.empty() )
        {
            std::ostringstream thePortStringStream;
            thePortStringStream << inPortNumber;

            theSetProxyStatus = axis2_svc_client_set_proxy_with_auth(
axis2_stub_get_svc_client( theStub, theEnvironment ),
                   
theEnvironment,
                   
const_cast<char*>( inHost.c_str() ),
                   
const_cast<char*>( thePortStringStream.str().c_str() ),
                                                                      (
inUserName.empty() ? NULL : const_cast<char*>( inUserName.c_str() ) ),
                                                                      (
inPassword.empty() ? NULL : const_cast<char*>( inPassword.c_str() ) ) );

        }

        if ( AXIS2_SUCCESS == theSetProxyStatus )
        {
            adb_MyServiceCall_t* theDoServiceCallRequest =
adb_MyServiceCall_create( theEnvironment );

            if ( theMyServiceCallRequest )
            {
                axis2_status_t theSetRequestXMLStatus =
adb_MyServiceCall_set_RequestXML( theMyServiceCallRequest,
                   
theEnvironment,
                   
inRequestString.c_str() );

                if ( AXIS2_SUCCESS == theSetRequestXMLStatus )
                {
                    adb_MyServiceCallResponse_t* theMyServiceCallResponse =
                   
axis2_stub_op_MyService_MyServiceCall( theStub,
                   
theEnvironment,
                   
theMyServiceCallRequest );
                    if ( theMyServiceCallResponse  )
                    {
                        axis2_char_t* theMyServiceCallResultValue =
                   
adb_MyServiceCallResponse_get_MyServiceCallResult( theMyServiceCallResponse,
                   
theEnvironment );

                            if ( theMyServiceCallResultValue )
                            {
                                outResponseString.assign(
theMyServiceCallResultValue );
                   
...

If I build axis2c with curl, then connecting through a proxy doesn¹t work at
all, even without authentication.

Is my code wrong or is this a bug in the axis2c library?

Kr
Halewijn

AW: Proxy authentication

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Hi Halewijn,

 

I strongly recommend to sniff in a Wireshark between Client and Proxy
herby. Then use first a client which works and safe recorded protocols.
Then take your axis2 client and see what goes on. I am nearly sure that
your client works with basic Authentication but your proxy server
intends to use a more cryptic protocol like Digest or NTLM or some form
of auto negotiating, in which case it tries to use NTLM first. You
should deliver up-front a hint to the proxy that you intend to use basic
authentication. 

 

I had to do so for SVN working on OpenVMS. All was working fine with SVN
on PC as this understands auto negotiating and then use basic
authentication came to work. But not so on OpenVMS. I had to use a java
switch -Dhttp.auth.preference=Basic while starting SVNkit (a java impl),
and all works fine as the Proxy was responding correctly to a basic
Authentication Request.

 

Josef

 

 

Von: Halewijn Geerts [mailto:halewijng@enfocus.com] 
Gesendet: Freitag, 10. Juni 2011 16:18
An: Apache AXIS C User List
Betreff: Proxy authentication

 

Hi,

I have a client application that connects to a web service through https
using axis2c 1.6.0. If I try to connect through a proxy that requires
authentication, I can't connect to the service. If I use a proxy that
doesn't require authentication, it works. I used
axis2_svc_client_set_proxy_with_auth to set the proxy.

I set up a squid proxy server and used basic authentication through a
custom written authenticator so I could print what the input was, but
nothing gets printed. I tested the proxy using both Safari and Firefox
and everything works correctly. I also tried to connect to the service
via the proxy ( with authentication ) using the curl command line tool
and that also worked correctly.

I generated client code from the service wsdl file using WSDL2C. 

This is the code I use to connect to the service:

...

axutil_error* theError = NULL;
axutil_env_t* theEnvironment = NULL;
axis2_stub_t* theStub = NULL;
axis2_status_t theSetProxyStatus = AXIS2_SUCCESS;

theError = axutil_error_create( axutil_allocator_init( NULL ) );
theEnvironment = axutil_env_create_with_error( axutil_allocator_init(
NULL ), theError );

if ( theEnvironment )
{
       theStub = axis2_stub_create_MyService( theEnvironment,
                                           inAxis2cFolder.c_str(),
                                           inMyServiceAddress.c_str() );

    if ( theStub  )
    {
        if ( ! inHost.empty() )
        {
            std::ostringstream thePortStringStream;
            thePortStringStream << inPortNumber;

            theSetProxyStatus = axis2_svc_client_set_proxy_with_auth(
axis2_stub_get_svc_client( theStub, theEnvironment ),
 
theEnvironment,
 
const_cast<char*>( inHost.c_str() ),
 
const_cast<char*>( thePortStringStream.str().c_str() ),
                                                                      (
inUserName.empty() ? NULL : const_cast<char*>( inUserName.c_str() ) ),
                                                                      (
inPassword.empty() ? NULL : const_cast<char*>( inPassword.c_str() ) ) );

        }

        if ( AXIS2_SUCCESS == theSetProxyStatus )
        {
            adb_MyServiceCall_t* theDoServiceCallRequest =
adb_MyServiceCall_create( theEnvironment );

            if ( theMyServiceCallRequest )
            {
                axis2_status_t theSetRequestXMLStatus =
adb_MyServiceCall_set_RequestXML( theMyServiceCallRequest,
 
theEnvironment,
 
inRequestString.c_str() );

                if ( AXIS2_SUCCESS == theSetRequestXMLStatus )
                {
                    adb_MyServiceCallResponse_t*
theMyServiceCallResponse =
 
axis2_stub_op_MyService_MyServiceCall( theStub,
 
theEnvironment,
 
theMyServiceCallRequest );
                    if ( theMyServiceCallResponse  )
                    {
                        axis2_char_t* theMyServiceCallResultValue =
 
adb_MyServiceCallResponse_get_MyServiceCallResult(
theMyServiceCallResponse,
 
theEnvironment );

                            if ( theMyServiceCallResultValue )
                            {
                                outResponseString.assign(
theMyServiceCallResultValue );
                            
...

If I build axis2c with curl, then connecting through a proxy doesn't
work at all, even without authentication.

Is my code wrong or is this a bug in the axis2c library?

Kr
Halewijn