Thanks, Colm. I was able to get past this hurdle and am on to the next one. 

For others experiencing the same hurdle, the link Colm provided above does
not include sample code. If you go to the WS-SecurityPolicy page
(http://cxf.apache.org/docs/ws-securitypolicy.html) you will see sample code
that shows one method of configuring properties that guided me to a
solution. 

If you are new to CXF as I am, you may be struggling with the various means
by which to set configurations. Here are two ways to configure an expected
audience for the client.

1. Set the configuration in the xml file. In our case we have a servlet.xml.

   <jaxws:client name="{http://cxf.apache.org}ThePortClassName";
      createdFromAPI="true">
      <jaxws:properties>
         <entry key="security.audience-restrictions"
             value="theExpectedAudience"/>
             ...
      </jaxws:properties>
   </jaxws:client>

2. Set the configuration in Java. In our case, the client class. And as a
bonus, I've included how to set the URL to the target service if for some
reason it is different than what the WSDL defines.

                URL  url = "path_to_the_wsdl";
                QName qName = new QName("http://service_url_from_the_wsdl";,
"service_name_from_wsdl");
                ThePortClassName port;
                String newEndpointURL = 
"https://subdomain.domain.com/service_endpoint";;

                Service service = new Service(url, qName);
                port = service.getService();

                BindingProvider bp = (BindingProvider) port;

                
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
newEndpointURL);
                bp.getRequestContext().put("security.audience-restrictions",
"theExpectedAudience"); 

                Client client = ClientProxy.getClient(port);

Hopefully this helps save someone a few days of searching.






-----
Regards,
RobCodes
--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Reply via email to