Search in sources :

Example 6 with WSAddressingFeature

use of org.apache.cxf.ws.addressing.WSAddressingFeature in project cxf by apache.

the class WSAClientServerTest method testCxfWsaFeature.

@Test
public void testCxfWsaFeature() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(AddNumbersPortType.class);
    factory.setAddress("http://localhost:" + PORT + "/jaxws/add");
    factory.getFeatures().add(new WSAddressingFeature());
    AddNumbersPortType port = (AddNumbersPortType) factory.create();
    ((BindingProvider) port).getRequestContext().put("ws-addressing.write.optional.replyto", Boolean.TRUE);
    assertEquals(3, port.addNumbers(1, 2));
    assertLogContains(output.toString(), "//wsa:Address", "http://www.w3.org/2005/08/addressing/anonymous");
    assertLogContains(input.toString(), "//wsa:RelatesTo", getLogValue(output.toString(), "//wsa:MessageID"));
}
Also used : WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 7 with WSAddressingFeature

use of org.apache.cxf.ws.addressing.WSAddressingFeature in project cxf by apache.

the class Server method run.

protected void run() {
    setBus(BusFactory.getDefaultBus());
    Object implementor = new AddNumberImpl();
    String address = "http://localhost:" + PORT + "/AddNumberImplPort";
    ep1 = new EndpointImpl(implementor);
    ep1.getFeatures().add(new WSAddressingFeature());
    ep1.publish(address);
    ep2 = new EndpointImpl(new AddNumberImplNoAddr());
    ep2.publish(address + "-noaddr");
}
Also used : WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl)

Example 8 with WSAddressingFeature

use of org.apache.cxf.ws.addressing.WSAddressingFeature in project cxf by apache.

the class Server method run.

protected void run() {
    Object implementor = new AddNumberReg();
    String address = "http://localhost:" + PORT + "/jaxws/add";
    EndpointImpl ep;
    ep = new EndpointImpl(BusFactory.getThreadDefaultBus(), implementor, null, getWsdl());
    ep.getFeatures().add(new WSAddressingFeature());
    ep.publish(address);
    eps.add(ep);
    implementor = new AddNumberNonAnon();
    address = "http://localhost:" + PORT + "/jaxws/addNonAnon";
    ep = new EndpointImpl(BusFactory.getThreadDefaultBus(), implementor, null, getWsdl());
    ep.getFeatures().add(new WSAddressingFeature());
    ep.publish(address);
    eps.add(ep);
    implementor = new AddNumberOnlyAnon();
    address = "http://localhost:" + PORT + "/jaxws/addAnon";
    ep = new EndpointImpl(BusFactory.getThreadDefaultBus(), implementor, null, getWsdl());
    ep.getFeatures().add(new WSAddressingFeature());
    ep.publish(address);
    eps.add(ep);
}
Also used : WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl)

Example 9 with WSAddressingFeature

use of org.apache.cxf.ws.addressing.WSAddressingFeature in project cxf by apache.

the class JaxWsEndpointImpl method extractWsdlExtensibilities.

private void extractWsdlExtensibilities(EndpointInfo endpoint) {
    List<ExtensibilityElement> portExtensors = getExtensors(endpoint);
    List<ExtensibilityElement> bindingExtensors = getExtensors(endpoint.getBinding());
    // check the extensions under <wsdl:binding>
    checkRespectBindingFeature(bindingExtensors);
    Collection<BindingOperationInfo> bindingOperations = endpoint.getBinding().getOperations();
    if (null != bindingOperations) {
        Iterator<BindingOperationInfo> iterator = bindingOperations.iterator();
        while (iterator.hasNext()) {
            BindingOperationInfo operationInfo = iterator.next();
            BindingMessageInfo inputInfo = operationInfo.getInput();
            BindingMessageInfo outputnfo = operationInfo.getOutput();
            Collection<BindingFaultInfo> faults = operationInfo.getFaults();
            // check the extensions under <wsdl:operation>
            checkRespectBindingFeature(getExtensors(operationInfo));
            // check the extensions under <wsdl:input>
            checkRespectBindingFeature(getExtensors(inputInfo));
            // check the extensions under <wsdl:output>
            checkRespectBindingFeature(getExtensors(outputnfo));
            if (null != faults) {
                Iterator<BindingFaultInfo> faultIterator = faults.iterator();
                while (faultIterator.hasNext()) {
                    BindingFaultInfo faultInfo = faultIterator.next();
                    // check the extensions under <wsdl:fault>
                    checkRespectBindingFeature(getExtensors(faultInfo));
                }
            }
        }
    }
    if (hasUsingAddressing(bindingExtensors) || hasUsingAddressing(portExtensors)) {
        WSAddressingFeature feature = new WSAddressingFeature();
        if (addressingRequired(bindingExtensors) || addressingRequired(portExtensors)) {
            feature.setAddressingRequired(true);
        }
        addAddressingFeature(feature);
    }
    extractWsdlEprs(endpoint);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 10 with WSAddressingFeature

use of org.apache.cxf.ws.addressing.WSAddressingFeature in project cxf by apache.

the class JaxWsEndpointImpl method resolveFeatures.

public final void resolveFeatures() {
    AddressingFeature addressing = getAddressingFeature();
    if (addressing == null) {
        return;
    }
    if (addressing.isEnabled()) {
        WSAddressingFeature feature = getWSAddressingFeature();
        if (feature == null) {
            feature = new WSAddressingFeature();
            addAddressingFeature(feature);
        }
        feature.setAddressingRequired(addressing.isRequired());
        feature.setResponses(addressing.getResponses().toString());
    } else {
        removeAddressingFeature();
        getEndpointInfo().setProperty("org.apache.cxf.ws.addressing.MAPAggregator.addressingDisabled", Boolean.TRUE);
    }
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature)

Aggregations

WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)17 Test (org.junit.Test)8 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)3 IOException (java.io.IOException)2 QName (javax.xml.namespace.QName)2 BusException (org.apache.cxf.BusException)2 Client (org.apache.cxf.endpoint.Client)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 Server (org.apache.cxf.endpoint.Server)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)2 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)2 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 AbstractCXFTest (org.apache.cxf.test.AbstractCXFTest)2 Conduit (org.apache.cxf.transport.Conduit)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashMap (java.util.HashMap)1