axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saminda Abeyruwan <sami...@opensource.lk>
Subject [Axis2]Re: "No credentials available for NTLM"
Date Thu, 05 Jan 2006 04:45:55 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Following code will allow you to connect to MS Share Point with
"Integrated Windows authentication" and "Basic authentication on MS
Server  2003 using Axis2 client.

public class Client {
    private static String toEpr =
"http://msserver:8008/_vti_bin/DWS.asmx?WSDL";

    public static void main(String[] args) throws AxisFault {
        HttpTransportProperties.ProxyProperties proxy = new
HttpTransportProperties().new ProxyProperties();

        proxy.setUserName("msserver\\user");
        proxy.setPassWord("pass");

        Options options = new Options();
        options.setTo(new EndpointReference(toEpr));
        options.setProperty(HTTPConstants.PROXY,proxy);

        ServiceClient serviceClient = new ServiceClient();
        serviceClient.setOptions(options);
        OMElement result = serviceClient.sendReceive(getPayload());

        try {
            XMLStreamWriter writer = XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(System.out);
            result.serialize(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }
    }

    private static OMElement getPayload() {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace(
                "http://schemas.microsoft.com/sharepoint/soap/dws/", "dws");
        OMElement method = fac.createOMElement("FindDoc", omNs);
        OMElement value = fac.createOMElement("Text", omNs);
        value.addChild(fac.createText(value, "Axis2 Echo String "));
        method.addChild(value);
        System.out.println(method.getText());
        return method;
    }
}

To do NTLM authentication, one  needs to fill the
HttpTransportProperties.ProxyProperties been with following

proxy.setProxyName("xxyy");
proxy.setProxyPort("<some integer>");

The prior will be the runtime setting of Basic/NTLM authentication.
Apart from that one can use axis2.xml to configure the authentication.
So one has to fill the axis2.xml as follows,

...

<transportSender name="http"
class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
        <parameter name="PROXY" proxy_host="proxy_host_name"
proxy_port="proxy_host_port"
locked="true>userName:domain:passWord</parameter>
</transportSender>
...


The prior will help you out to do Basic/NTLM Authentication using Axis2.
For more detail please be kind enough to use http-transport.html in
xdocs folder in Axis2 distribution and need more help please buzz us
anytime.

Thank you

Saminda

Serg Nesterenko wrote:
> public class Client2 {
> 
>    private static String toEpr =
> "http://msserver:8008/_vti_bin/DWS.asmx?WSDL";
> 
>    public static void main(String[] args) throws AxisFault {
>        Authenticator.setDefault(new AxisAuthenticator("msserver\\user",
> "pass"));
>              Options options = new Options();
>        options.setTo(new EndpointReference(toEpr));
>        options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
>        options.setUseSeparateListener(false);
>        options.setProperty(Constants.Configuration.ENABLE_REST,
> Constants.VALUE_FALSE);
>        options.setProperty(Constants.USER_NAME, "msserver\\user");
>        options.setProperty(Constants.PASSWORD, "pass");
>              Call call = new Call();
>        call.setClientOptions(options);
>        OMElement result = call.invokeBlocking("FindDoc", getPayload());
> 
>        try {
>            XMLStreamWriter writer =
> XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
>            result.serialize(writer);
>            writer.flush();
>        } catch (XMLStreamException e) {
>            e.printStackTrace();
>        } catch (FactoryConfigurationError e) {
>            e.printStackTrace();
>        }
>    }
> 
>    private static OMElement getPayload() {
>        OMFactory fac = OMAbstractFactory.getOMFactory();
>        OMNamespace omNs =
> fac.createOMNamespace("http://schemas.microsoft.com/sharepoint/soap/dws/",
> "dws");
>        OMElement method = fac.createOMElement("FindDoc", omNs);
>        OMElement value = fac.createOMElement("Text", omNs);
>        value.addChild(fac.createText(value, "Axis2 Echo String "));
>        method.addChild(value);
>        System.out.println(method.getText());
>        return method;
>    }
> }
> 
> Thank you
> 
> 
> Saminda Abeyruwan wrote:
> 
> Please post your client code, So we can simulate it here.
> 
> Thank you
> 
> Saminda
> 
> Serg Nesterenko wrote:
>  
> 
>>>> Hello!
>>>> I used Axis 2 (0.93).
>>>> I try connect to MS Share Point with "Integrated Windows authentication"
>>>> and "Basic authentication (also tried swith off)" on MS Server  2003.
>>>>
>>>> My code contain:
>>>>       options.setProperty(Constants.USER_NAME, "msserver\\user");
>>>>       options.setProperty(Constants.PASSWORD, "pass");
>>>> and
>>>>      Authenticator.setDefault(new
>>>> AxisAuthenticator("msserver\\user","user"));
>>>>
>>>> And result:
>>>> - Invoking Handler 'AddressingOutHandler' in Phase 'MessageOut'
>>>> - ntlm authentication scheme selected
>>>> - No credentials available for NTLM <any realm>@msserver:8008
>>>>
>>>> org.apache.axis2.AxisFault: Transport error 401 . Error Message is
>>>> <!DOCTYPE HTML ............
>>>> HTTP Error 401.2 - Unauthorized: Access is denied due to server
>>>> configuration.<br>Internet Information Services (IIS)
>>>> .................
>>>>   at
>>>> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:265)
>>>>
>>>>
>>>>   at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:93)
>>>>   at
>>>> org.apache.axis2.client.InOutMEPClient.send(InOutMEPClient.java:392)
>>>>   at
>>>> org.apache.axis2.client.InOutMEPClient.invokeBlocking(InOutMEPClient.java:154)
>>>>
>>>>
>>>>   at org.apache.axis2.client.Call.invokeBlocking(Call.java:91)
>>>>   at userguide.clients.Client2.main(Client2.java:73)
>>>>
>>>> Why this don't work?
>>>> Why i cannot to switch Client to "Basic authentication"?
>>>> I not used "Code Generator Wizard".
>>>>
>>>>   
> 
> 

>>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDvKSCYmklbLuW6wYRAlgMAJ0fjWGGf8A4ZmSbCw4gxm1IQnL2oQCdFm8I
wfCjoyOiu+SfBIndUL9mnoM=
=9G7A
-----END PGP SIGNATURE-----

Mime
View raw message