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 "KUMAR,PANKAJ (HP-Cupertino,ex1)" <pa...@hp.com> on 2003/04/23 06:40:05 UTC
Is this a JAX-RPC limitation or have I missed something obvious?
Hi,
I am trying to use Servlet deployment descriptor declarations to apply
access control to an Axis services. This works fine for accessing the WSDL
or service through a browser (Imean, the browser throws up an
username/password dialog box and proceeds to dowload the WSDL). However,
when I try to access the service through a DII client (source code given
below ), I get an exception. I suspected that the code is trying to access
the WSDL from Axis and is failing there because Axis servlet is asking for
authentication. SO I stored the WSDL in file and specified wsdlAddr as
"file:temp.wsdl", a URL pointing to a local file. This worked fine.
Now, JAX-RPC allows me to set the USERNAME_PROPERTY and USERNAME_PASSWORD in
a Call object but not in ServiceFactory which retrieves the WSDL document.
Is this a JAX-RPC limitation or have I missed something obvious?
----------------------------------------------------------------------------
------------------------------------------------------------------------
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
public class EchoClient1 {
public static void main(String [] args) throws Exception {
String epAddr =
"http://localhost:8080/axis/services/StringEchoPort1";
String wsdlAddr = epAddr + "?wsdl";
String nameSpaceUri = "http://www.pankaj-k.net/jsbook/examples/";
String svcName = "StringEchoService1";
String portName = "StringEchoPort1";
java.net.URL wsdlUrl = new java.net.URL(wsdlAddr);
ServiceFactory svcFactory = ServiceFactory.newInstance();
QName svcQName = new QName(nameSpaceUri, svcName);
Service svc = svcFactory.createService(wsdlUrl, svcQName);
String username = "blah";
String password = "blah";
Call call = (Call) svc.createCall();
call.setTargetEndpointAddress(epAddr);
call.setOperationName( new QName(nameSpaceUri, "echo") );
call.setPortTypeName( new QName(nameSpaceUri, portName) );
call.setProperty(Call.USERNAME_PROPERTY, username);
call.setProperty(Call.PASSWORD_PROPERTY, password);
Object arg = "Hi, How are you?";
System.out.println("sending: " + arg );
String res = (String) call.invoke(new Object[] {arg});
System.out.println("received: " + res );
}
}
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--------
Thanks in advance,
Pankaj Kumar.