This discussion is archived
0 Replies Latest reply: Jun 21, 2013 4:06 PM by user592676 RSS

WEB SERVICE: DISPATCH CLIENT WITH SECURITY FEATURES: DOES NOT ADD SECURITY DETAILS IN HEADER

user592676 Newbie
Currently Being Moderated

Hi All,

I am unable to invoke a secured webservice using a (dynamic) dispatch client.

It seems that the security information for the webservice call , which is set on the port/WSBindingProvider, is not being added to the SOAP header when the webservice call is made.

 

When I set the same information on the port/WSBindingProvider of a generated webservice proxy(static client) the webservice call goes thru. fine and gets the proper response.

 

Attached inline below are the dynamic proxy code and the request made to the webservice and the error message.

 

Please take a look.

 

Appreciate any pointers on the issue.

Thanks

======================================Code============================

    public static void dispatch3() throws Exception {

        String url_str = "http://localhost:10615/Application1-Project2-context-root/HelloPort?wsdl";

        URL url = new URL(url_str);

       

        QName serviceName = new QName("http://project2/", "HelloService");

        service = Service.create(serviceName);

        service.addPort(new QName("HelloService", "HelloPort"), SOAPBinding.SOAP11HTTP_BINDING, url_str);

        System.out.println("Setup complete.");

       SecurityPolicyFeature[] securityFeature =

                new SecurityPolicyFeature[] { new SecurityPolicyFeature("policy:oracle/wss11_username_token_with_message_protection_client_policy") };

        Dispatch<Source> sourceDispatch =

                 service.createDispatch(new QName("HelloService", "HelloPort"), Source.class, Service.Mode.PAYLOAD ,securityFeature);

 

        String l_StrRequest = "<ns1:getHello xmlns:ns1=\"http://project2/\" />";

        InputStream is = new ByteArrayInputStream(l_StrRequest.getBytes());

        Source streamSourceReq = new StreamSource(is);

       

        WSBindingProvider wsbp = (WSBindingProvider)sourceDispatch;

                

            Map<String, Object> requestContext = wsbp.getRequestContext();

            requestContext.put(BindingProvider.USERNAME_PROPERTY, "weblogic");

            requestContext.put(BindingProvider.PASSWORD_PROPERTY, "weblogic1");

            requestContext.put(ClientConstants.WSSEC_KEYSTORE_TYPE, "JKS");

            requestContext.put(ClientConstants.WSSEC_KEYSTORE_LOCATION, "D:\\default-keystore.jks");

            requestContext.put(ClientConstants.WSSEC_KEYSTORE_PASSWORD, "welcome1");

 

        Source result = sourceDispatch.invoke(streamSourceReq);

        String res = getStringFromInputStream(((StreamSource)result).getInputStream());

        System.out.println(res);

                    

    }

==================================================================================

 

===========================webservice request=============================

6/21/2013 15:23:58.015; 504: Client to Server (743 bytes, Incomplete last line)

POST /Application1-Project2-context-root/HelloPort?wsdl HTTP/1.1

Host: localhost:7101

Connection: Keep-Alive, TE

TE: trailers, deflate, gzip, compress

User-Agent: Oracle JAX-WS 2.1.5 Oracle HTTPClient Version 10h

Proxy-Authorization:

Authorization: Basic d2VibG9naWM6d2VibG9naWMx

Soapaction: ""

Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

X-HTTPAnalyzer-Rules: 7@localhost:8099

Accept-Encoding: gzip, x-gzip, compress, x-compress

ECID-Context:

Content-type: text/xml;charset="utf-8"

Content-Length: 176

 

 

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns1:getHello xmlns:ns1="http://project2/"/></S:Body></S:Envelope>

===========================================================================

 

=========================Exception===========================

xception breakpoint occurred at line -1 of .

javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header

  at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:197)

  at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)

  at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:246)

  at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:273)

  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

  at java.lang.reflect.Method.invoke(Method.java:597)

  at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:84)

  at $Proxy20.invoke(Unknown Source)

  at project5.DispatchClient2.dispatch3(DispatchClient2.java:167)

  at project5.DispatchClient2.main(DispatchClient2.java:247)

Caused by: javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header

  at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:231)

======================================================================================

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points