You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jyothishree Honnavalli <jh...@rightanswers.com> on 2005/05/24 23:18:00 UTC

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.j
ava: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.Respon
se.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
------------------------------------------------------------------------
-