use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class AbstractMultiplexDestination method getAddressWithId.
/**
* Builds an new endpoint reference using the current target reference as a template.
* The supplied id is endcoded using a reference parameter.
* This requires the ws-a interceptors to propagate the reference parameters
* on subsequent invokes using the returned reference.
* @param id the id to encode in the new reference
* @return the new reference with the id encoded as a reference parameter
* @see org.apache.cxf.transport.MultiplexDestination#getAddressWithId(java.lang.String)
*/
public EndpointReferenceType getAddressWithId(String id) {
EndpointReferenceType epr = EndpointReferenceUtils.duplicate(EndpointReferenceUtils.mint(reference, bus));
ReferenceParametersType newParams = new org.apache.cxf.ws.addressing.ObjectFactory().createReferenceParametersType();
ReferenceParametersType existingParams = epr.getReferenceParameters();
if (null != existingParams) {
newParams.getAny().addAll(existingParams.getAny());
}
newParams.getAny().add(new JAXBElement<String>(MULTIPLEX_ID_QNAME, String.class, id));
epr.setReferenceParameters(newParams);
return epr;
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetXPath10Test method getBooleanTrueTest.
@Test
public void getBooleanTrueTest() throws XMLStreamException {
String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("count(//b) = 2");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("true", value.getContent().get(0));
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetXPath10Test method getImpliedLanguageTest.
@Test
public void getImpliedLanguageTest() throws XMLStreamException {
String content = "<root><a><b>Text</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.getContent().add("/root/a/b");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("b", ((Element) value.getContent().get(0)).getLocalName());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetXPath10Test method getWithNamespaceTest.
@Test
public void getWithNamespaceTest() throws XMLStreamException {
String content = "<ns:root xmlns:ns=\"www.example.org\"><ns:a><ns:b>Text</ns:b></ns:a></ns:root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("/ns:root/ns:a/ns:b");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("b", ((Element) value.getContent().get(0)).getLocalName());
Assert.assertEquals("www.example.org", ((Element) value.getContent().get(0)).getNamespaceURI());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentPutAddTest method addExistingAttributeTest.
@Test(expected = SOAPFaultException.class)
public void addExistingAttributeTest() throws XMLStreamException {
String content = "<a foo=\"1\"/>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
expression.getContent().add("/a");
Document doc = DOMUtils.getEmptyDocument();
Element addedAttr = doc.createElementNS(FragmentDialectConstants.FRAGMENT_2011_03_IRI, FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME);
addedAttr.setAttributeNS(FragmentDialectConstants.FRAGMENT_2011_03_IRI, FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR, "foo");
addedAttr.setTextContent("2");
ValueType value = new ValueType();
value.getContent().add(addedAttr);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
client.put(request);
resource.destroy();
}
Aggregations