cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j1234d2003 <j1234d2...@yahoo.com>
Subject Unable to set ServiceName and PortName in AddressingProperties for WS-Addressing
Date Thu, 15 Aug 2013 00:42:26 GMT
I am using Dispatch API to invokeAsync and set the AddressingProperties in
the
requestContext of the dispatch.

i.e. requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES,
createAddressingProperties());

I need the service to send the response to a specific port-name and
service-name i.e I need:

<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
  <Address>http://...</Address>
  <Metadata>
    <wsaw:ServiceName xmlns:wsaw="http://www.w3.org/2006/02/addressing/wsdl"
EndpointName="MySvcPort">MySvc</wsaw:ServiceName>
  <Metadata>
</ReplyTo>

I am programatically setting the AddressProperties and am able to send basic
WS-Addressing headers but I am unable to figure out how to set the
ServiceName and EndpointName in a Reply-To header. Reply-To header with just
Address works fine.

I believe, it is necessary to use EndpointReferenceType with a MetadataType.
The MetadataType.getAny() should allow adding required information but I am
not able to successfully do so.

private AddressingProperties createAddressingProperties()
{
...
  QName svcName = new QName("http://....", "MySvcService");
  String portName = "MySvcPort";

  org.apache.cxf.ws.addressing.ObjectFactory factory = new
org.apache.cxf.ws.addressing.ObjectFactory();
  EndpointReferenceType ref =  factory.createEndpointReferenceType();

  MetadataType metaType = mWsaObjectFactory.createMetadataType();
  ref.setMetadata(metaType);

This portion should be okay - what do we use after this:
CASE 1:
  AttributedAnyType serviceName =
mWsaObjectFactory.createAttributedAnyType();
  serviceName.setAny(svcName);
  metaType.getAny().add(serviceName);

Result:
javax.xml.bind.MarshalException Caused by: com.sun.istack.SAXException2:
unable to marshal type "org.apache.cxf.ws.addressing.AttributedAnyType" as
an element because it is missing an @XmlRootElement annotation

CASE 2:
  AttributedQNameType serviceName =
mWsaObjectFactory.createAttributedQNameType();
  serviceName.setValue(SERVICE_QNAME);
  metaType.getAny().add(serviceName);

Result:
javax.xml.bind.MarshalException Caused by: com.sun.istack.SAXException2:
unable to marshal type "org.apache.cxf.ws.addressing.AttributedQNameType" as
an element because it is missing an @XmlRootElement annotation

CASE 3:
  org.apache.cxf.wsdl.EndpointReferenceUtils.setServiceAndPortName(ref,
SERVICE_QNAME, PORT_NAME);

Result:
Caused by: javax.xml.bind.JAXBException:
org.apache.cxf.ws.addressing.wsdl.ServiceNameType is not known to this
context
Note here that this seems to be meant for
http://www.w3.org/2006/05/addressing/wsdl and not
http://www.w3.org/2005/08/addressing 

Another related question that comes to mind is how does one add the
ReferenceParameters? The reference parameters shall involve custom
namespaces and user-defined data structures and therefore, is there a way to
do so?

Thanks
-JD



--
View this message in context: http://cxf.547215.n5.nabble.com/Unable-to-set-ServiceName-and-PortName-in-AddressingProperties-for-WS-Addressing-tp5732460.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message