Hi ,

 

I found on apache axis-user mail archives discussion on Basic authentication. I looked at one of the solutions and tried using the stub as well…still getting 401 error. Please  let me know how you figured it out.

 

import org.apache.axis.client.*;

import javax.xml.namespace.*;

 

import com.microsoft.webservices.SharePointPortalServer.WebQueryService.*;

 

 

public class SoapWsdlClient

{

   public String callWebService(String qry)

 

   {

 

            String result= null;

               try

               {

 

                                     QueryServiceLocator os           = new QueryServiceLocator();

                                     QueryServiceSoapStub stub = (QueryServiceSoapStub)   os.getQueryServiceSoap();

 

                                    stub.setUsername("username");

                                    stub.setPassword("password");

                                    result = stub.query(qry);

                        }

                        catch (Exception e)

                        {

                        e.printStackTrace();

                        }

    return result;

   }

 

 

 

            public static void main(String[] args)

            {

                        String queryxml ="<?xml version=\"1.0\" encoding=\"utf-8\" ?><QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\"><Query domain=\"QDomain\"><SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats><Context><QueryText language=\"en-US\" type=\"STRING\">cannot print</QueryText></Context><Range><StartAt>1</StartAt><Count>500</Count></Range></Query></QueryPacket>";

                        SoapWsdlClient SoapWsdlClient = new SoapWsdlClient();

                        String result= SoapWsdlClient.callWebService(queryxml);

                        System.out.println(result);

            }

 

}

 

 

 

 

-----Original Message-----
From: Jyothishree Honnavalli
Sent:
Tuesday, May 24, 2005 5:18 PM
To: axis-user@ws.apache.org
Subject: Basic Authentication

 

Hi,

 

     I’m trying to access Microsoft sharepoint webservice  from an axis client. I need to authenticate using Basic /NTLM authentication. I’m trying to set username and password

            call.setUsername("username");

            call.setPassword("passwd");

 

I also tried –

            call.setProperty("USERNAME_PROPERTY", "username");

            call.setProperty("PASSWORD_PROPERTY", "password");

 

I still get 401 error Please help me how to deal with this. I have also attached the code and error below.

 

Thanks.

Jyothi

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle)

log4j:WARN Please initialize the log4j system properly.

AxisFault

 faultCode: {http://xml.apache.org/axis/}HTTP

 faultSubcode:

 faultString: (401)Unauthorized

 faultActor:

 faultNode:

 faultDetail:

        {}:return code:  401

401 Unauthorized

        {http://xml.apache.org/axis/}HttpErrorCode:401

 

(401)Unauthorized

        at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:732)

        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)

        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

        at org.apache.axis.client.Call.invokeEngine(Call.java:2765)

        at org.apache.axis.client.Call.invoke(Call.java:2748)

        at org.apache.axis.client.Call.invoke(Call.java:2424)

        at org.apache.axis.client.Call.invoke(Call.java:2347)

        at org.apache.axis.client.Call.invoke(Call.java:1804)

        at SoapWsdlClient.<init>(SoapWsdlClient.java:23)

        at SoapWsdlClient.main(SoapWsdlClient.java:36)

Press any key to continue . . .

 

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

 

import java.net.*;

import org.apache.axis.client.*;

import javax.xml.namespace.*;

 

 

public class SoapWsdlClient

{

public SoapWsdlClient()

{

try

{

 

 

            String endPointAddress = "http://<server>/_vti_bin/search.asmx";

            Service service = new Service();

            Call call = ( Call )service.createCall();

            call.setTargetEndpointAddress( endPointAddress );

            call.setUsername("username");

            call.setPassword("passwd");

 

            call.setSOAPActionURI("urn:Microsoft.Search/Query");

            call.setOperationName( new QName("urn:Microsoft.Search.Query", "Query") );

            String returned = ( String) call.invoke( new Object[] { " <?xml version=\"1.0\" encoding=\"utf-8\" ?><QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\"><Query domain=\"QDomain\"><SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats><Context><QueryText language=\"en-US\" type=\"STRING\">cannot print</QueryText></Context><Range><StartAt>1</StartAt><Count>500</Count></Range></Query></QueryPacket>" } );

            System.out.println( "Soap returned: " + returned );

 

 

}

catch (Exception e)

{

e.printStackTrace();

}

}

 

public static void main(String[] args)

{

SoapWsdlClient SoapWsdlClient = new SoapWsdlClient();

}

}

 

-------------------------------------------------------------------------
Jyothishree Honnavalli

RightAnswers, LLC

67 Walnut Avenue

Suite 210

Clark, NJ 07066

Ph: 732-396-9010 Ext. 167

Fax 732-396-9011

-------------------------------------------------------------------------

 

Reply via email to