Thanks! You're absolutely right.

It seems the following line is redundant:
options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, https);

 - Kenneth


keith chapman wrote:
> 
> Noticed that you had
> 
> auth.setPassword(userName);
> auth.setUsername(password);
> 
> in your code. A mistake probably that caused the issue?
> 
> Thanks,
> Keith.
> 
> On Thu, Jul 3, 2008 at 8:07 PM, Odd Kenneth Oden
> <[EMAIL PROTECTED]>
> wrote:
> 
>>
>> Hello,
>>
>> I have been unable to successfully execute my WSDL-generated Axis2 1.4
>> client against a web service that uses HTTPS and basic authentication.
>>
>> After some extensive search on the Internet, I found some suggestions
>> which
>> I have tried to implement. I've managed to successfully do a HTTP get
>> against the service's WSDL-file using plain HTTPClient, but when I try to
>> implement what should basically be the same parameters on the service
>> stub,
>> I receive a "Transport error: 401 Error: Unauthorized" error message.
>>
>> I've included the source code for the successful HTTPClient code and the
>> not-so-successfull service stub:
>>
>>            ProtocolSocketFactory protocolSocketFactory = new
>> EasySSLProtocolSocketFactory();
>>            //ProtocolSocketFactory protocolSocketFactory = new
>> SSLProtocolSocketFactory();
>>            Protocol https = new Protocol("https", protocolSocketFactory,
>> 443);
>>
>>            HttpState state = new HttpState();
>>            state.setCredentials(new AuthScope(host, 443), new
>> UsernamePasswordCredentials(userName, password));
>>
>>            HttpClient httpclient = new HttpClient();
>>            httpclient.setState(state);
>>
>>            httpclient.getHostConfiguration().setHost(host, 443, https);
>>            GetMethod httpget = new GetMethod(wsdlPath);
>>            try {
>>              httpclient.executeMethod(httpget);
>>              System.out.println(httpget.getStatusLine());
>>            } finally {
>>              httpget.releaseConnection();
>>            }
>>
>>            HttpTransportProperties.Authenticator auth = new
>> HttpTransportProperties.Authenticator();
>>            auth.setPassword(userName);
>>            auth.setUsername(password);
>>            auth.setHost(host);
>>            auth.setPort(443);
>>
>>            SmsServiceStub service = new SmsServiceStub(endPoint);
>>            Options options = service._getServiceClient().getOptions();
>>            options.setProperty(HTTPConstants.AUTHENTICATE, auth);
>>            options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
>> https);
>>            options.setTimeOutInMilliSeconds(60 * 1000); //1 minute
>>
>>            SmsServiceStub.SubmitRsp resp = service.Submit(req);
>>
>> And the log:
>>
>> Running com.telenor.nwnsms.SmsServiceTest
>> 03.jul.2008 16:11:29
>> org.apache.commons.httpclient.auth.AuthChallengeProcessor
>> selectAuthScheme
>> INFO: basic authentication scheme selected
>> HTTP/1.1 200 OK
>> 03.jul.2008 16:11:30 org.apache.axis2.deployment.ModuleDeployer deploy
>> INFO: Deploying module: addressing-1.4
>> 03.jul.2008 16:11:31
>> org.apache.commons.httpclient.auth.AuthChallengeProcessor
>> selectAuthScheme
>> INFO: basic authentication scheme selected
>> 03.jul.2008 16:11:31 org.apache.commons.httpclient.HttpMethodDirector
>> processWWWAuthChallenge
>> INFO: Failure authenticating with BASIC ''@<removed>:443
>> 03.jul.2008 16:11:31 org.apache.axis2.transport.http.HTTPSender
>> sendViaPost
>> INFO: Unable to sendViaPost to url[https://<removed>]
>> org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
>>        at
>>
>> org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:298)
>>        at
>> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:192)
>>        at
>> org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
>>        at
>>
>> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
>>        at
>>
>> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
>>        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
>>        at
>>
>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
>>        at
>>
>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
>>        at
>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>>        at
>> com.telenor.mr2.channel.nwn.SmsServiceStub.Submit(SmsServiceStub.java:207)
>>        at
>> com.telenor.nwnsms.SmsServiceTest.testApp(SmsServiceTest.java:95)
>>        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:585)
>>        at junit.framework.TestCase.runTest(TestCase.java:154)
>>        at junit.framework.TestCase.runBare(TestCase.java:127)
>>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>>        at junit.framework.TestResult.run(TestResult.java:109)
>>        at junit.framework.TestCase.run(TestCase.java:118)
>>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>        at junit.framework.TestSuite.run(TestSuite.java:203)
>>        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:585)
>>        at
>> org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
>>        at
>>
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>>        at
>>
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>>        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:585)
>>        at
>>
>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
>>        at
>>
>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
>>
>> Thanks in advance!
>> Kenneth
>> --
>> View this message in context:
>> http://www.nabble.com/Axis2-SOAP-client-and-HTTPS-based-server-using-basic-authentication-tp18260167p18260167.html
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> Keith Chapman
> Senior Software Engineer
> WSO2 Inc.
> Oxygenating the Web Service Platform.
> http://wso2.org/
> 
> blog: http://www.keith-chapman.org
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Axis2-SOAP-client-and-HTTPS-based-server-using-basic-authentication-tp18260167p18274670.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to