开发者

HTTP Basic Authentication for WEBService call

I trying to invoke a web service, which has an Basic HTTP Authentication. I generated the client code using the WSDL2JAVA tool from AXIS.

But I am not able to set the username and password to the webservice call.

I tried to have them in the endpoint url as

http://username:password@somwserver/wsdl

But I am getting the unauthorized error for this. I am trying to figure out a way to get this set to my call in the Java code....

Note : I am able to invoke the same service via the soapUI and get the results. I provided the username and password in the "Aut" tab on the request.

Here is some of the code snippets of my Stub, if this is userful for you

       _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);


    _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
            targetEndpoint));
    _serviceClient.getOptions().setUseSeparateL开发者_运维知识库istener(useSeparateListener);

        //adding SOAP soap_headers
     _serviceClient.addHeadersToEnvelope(env);
    // set the message context with that soap envelope
    _messageContext.setEnvelope(env);

    // add the message contxt to the operation client
    _operationClient.addMessageContext(_messageContext);

    //execute the operation client
    _operationClient.execute(true);

Any inputs will be greatly appreciated!!


 HttpTransportProperties.Authenticator
                       auth = new HttpTransportProperties.Authenticator();
            auth.setUsername("username");
            auth.setPassword("password");

 _serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE,auth);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜