No, that does not work. The error message is still the same: "Anonymous login not allowed"

Here is how I tried:


    public void testRawConnection_OK() throws Exception {

        java.net.Authenticator.setDefault(
            new java.net.Authenticator(){

                @Override
protected java.net.PasswordAuthentication getPasswordAuthentication(){
                    return new java.net.PasswordAuthentication(
                       USER_ID, PASSWORD.toCharArray());
                }

            }
           );

        // get Service
        PartnerWebServiceLocator locator = new PartnerWebServiceLocator();
        PartnerWebServiceSoap service = locator.getPartnerWebServiceSoap();

        // Aufruf "under test"
        ClsVacancy result =
service.getVacancy(rentalObjectID, checkIn, checkOut, ENVIRONMENT);

        // assert u. verify
        assertNotNull(result);

    }


Andrew Martin schrieb:
I think you can supply the authentication username and password like this:
java.net.Authenticator.setDefault(
 new java.net.Authenticator()
 {
  protected java.net.PasswordAuthentication getPasswordAuthentication()
  {
   return new java.net.PasswordAuthentication(
    "username", "password".toCharArray()); // Use your name/password
  }
 }
);

I think that should work regardless of how you invoke the service (Call,
proxy, etc.).

Andrew

Andy Pahne wrote:
I discovered the Users guide and the code examples. They all use Call.
But I find that a bit arkward, because then I'd have to deal with XSD
types, return types and such things.

If I compare with
ClsVacancy result =
 service.getVacancy(rentalObjectID, checkIn, checkOut, ENVIRONMENT);
that seems very complicated.

In the end, Axis generated all those objects like ClsVacancy for me and
I hoped not to have to deal with XML/XSD/SOAP details.

Andy







Andy Pahne schrieb:
Hello,

I am currently having my first experiences with web services and axis,
so this may be newbie questions.

I generated a client from WSDL that consumes one of our partner's web
services. (I used EclipseWTP to do so, but that part was easy and
succeeded, I think). EclipseWTP currently uses Axis 1, so the exact
version is 1.3.0.

I was playing around with a unit test:

    public void testRawConnection_no_authentication() throws Exception {

        // get Service
        PartnerWebServiceLocator locator = new
PartnerWebServiceLocator();
        PartnerWebServiceSoap service =
locator.getPartnerWebServiceSoap();


        try {

            // Aufruf "under test"
            @SuppressWarnings("unused")
            ClsVacancy result =
                service.getVacancy(rentalObjectID, checkIn, checkOut,
ENVIRONMENT);

            fail("expected RemoteException was NOT thrown");

        } catch (RemoteException expected) {

            assertNotNull(expected);
            assertTrue(expected.getMessage().contains("Anonymous login
not allowed"));

        }


    }





That test suceeds, because the Web Service is protected by basic http
authentication. But at least I am confident that I succesfully
connected to the service, because the recieved error message comes
from the remote system and not from Axis itself.


Here are my questions:


1. Is it correct to obtain the service proxy like this:

        // get Service
        PartnerWebServiceLocator locator = new
PartnerWebServiceLocator();
        PartnerWebServiceSoap service =
locator.getPartnerWebServiceSoap();


  I think it is correct, but can you confirm?




2. And how do I use basic http authentication when I have a password
and a username?
   I googled around and found a code snippet that used the Call class
(Interface ?), but I am not sure if that is the correct direction. And
the snippet also was not complete. I did not find anything apropriate
in  the FAQ.


Thanks,
Andy Pahne





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


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



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

Reply via email to