« Return to Thread: How to pass authetication to a web service...

How to pass authetication to a web service...

by krish1315 :: Rate this Message:

Reply to Author | View in Thread

Hello folks,,,

I am accessing a Externally deployed services through "Web Service Client wizard" of NetBeans...
These service require HTTP authetication -- User name and password...

I created the JAX-WS artifacts thrught wizard, Now when i am accessing these services through my Java code...

How should i pass authethication parameters...


following is the code to access the service

try { // Call Web Service Operation
   com.smed.imaging._240.ItkInterface service = new com.smed.imaging._240.ItkInterface();
   com.smed.imaging._240.ItkInterfaceSoap port = service.getItkInterfaceSoap();
   
    // TODO initialize WS operation arguments here
        java.lang.String inputXml = "<ServiceParms><OwnerList><Owner OwnerTypeName='MEDREC'><MedRecMRN>297368</MedRecMRN></Owner></OwnerList></ServiceParms>";
   // TODO process result here
   java.lang.String result = port.ikmSvcListRecords(inputXml);
   System.out.println("Result = "+result);
} catch (Exception ex) {
    ex.printStackTrace();
   // TODO handle custom exceptions here
}




It is throwing following exception

Failed to access the WSDL at: http://blrkf4aa/c9sl/html/IkmSvcInterface.asmx?wsdl. It failed with:
        Server returned HTTP response code: 401 for URL: http://blrkf4aa/c9sl/html/IkmSvcInterface.asmx?wsdl.
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
        at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:174)
        at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
        at javax.xml.ws.Service.<init>(Service.java:57)
        at com.smed.imaging._240.ItkInterface.<init>(ItkInterface.java:48)
        at EDMClient.main(EDMClient.java:20)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://blrkf4aa/c9sl/html/IkmSvcInterface.asmx?wsdl
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
        at java.net.URL.openStream(URL.java:1009)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:804)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:261)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:129)
        ... 7 more



I tried with inserting following before invoking service,....

   BindingProvider bp = (BindingProvider)port;
    Map<String,Object> map = bp.getRequestContext();
    map.put(BindingProvider.USERNAME_PROPERTY, "userName");
    map.put(BindingProvider.PASSWORD_PROPERTY,"password");


Still it is throwing the same excpetion....



Thanks,
Krishna

   



 « Return to Thread: How to pass authetication to a web service...

LightInTheBox - Buy quality products at wholesale price