Search in sources :

Example 6 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSAFaultToClientServerTest method testOneWayFaultTo.

@Test
public void testOneWayFaultTo() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
    Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature());
    EndpointReferenceType faultTo = new EndpointReferenceType();
    AddressingProperties addrProperties = new AddressingProperties();
    AttributedURIType epr = new AttributedURIType();
    String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo";
    epr.setValue(faultToAddress);
    faultTo.setAddress(epr);
    addrProperties.setFaultTo(faultTo);
    BindingProvider provider = (BindingProvider) greeter;
    Map<String, Object> requestContext = provider.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter");
    requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
    greeter.greetMeOneWay("test");
    // wait for the fault request
    int i = 2;
    while (HelloHandler.getFaultRequestPath() == null && i > 0) {
        Thread.sleep(500);
        i--;
    }
    assertTrue("FaultTo request fpath isn't expected", "/faultTo".equals(HelloHandler.getFaultRequestPath()));
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) AddressingFeature(javax.xml.ws.soap.AddressingFeature) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Greeter(org.apache.hello_world_soap_http.Greeter) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Test(org.junit.Test)

Example 7 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSAFromWSDLTest method getPort.

private AddNumbersPortTypeProxy getPort() throws Exception {
    URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
    assertNotNull("WSDL is null", wsdl);
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull("Service is null ", service);
    AddNumbersPortTypeProxy port = service.getAddNumbersPort(new AddressingFeature());
    updateAddressPort(port, PORT);
    return port;
}
Also used : AddNumbersService(org.apache.cxf.systest.ws.addr_feature.AddNumbersService) AddressingFeature(javax.xml.ws.soap.AddressingFeature) URL(java.net.URL) AddNumbersPortTypeProxy(org.apache.cxf.systest.ws.addr_feature.AddNumbersService.AddNumbersPortTypeProxy)

Example 8 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class JaxWsServiceFactoryBean method loadWSFeatureAnnotation.

private void loadWSFeatureAnnotation(Class<?> serviceClass, Class<?> implementorClass) {
    List<WebServiceFeature> features = new ArrayList<>();
    MTOM mtom = implInfo.getImplementorClass().getAnnotation(MTOM.class);
    if (mtom == null && serviceClass != null) {
        mtom = serviceClass.getAnnotation(MTOM.class);
    }
    if (mtom != null) {
        features.add(new MTOMFeature(mtom.enabled(), mtom.threshold()));
    } else {
        // deprecated way to set mtom
        BindingType bt = implInfo.getImplementorClass().getAnnotation(BindingType.class);
        if (bt != null && (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bt.value()) || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bt.value()))) {
            features.add(new MTOMFeature(true));
        }
    }
    Addressing addressing = null;
    if (implementorClass != null) {
        addressing = implementorClass.getAnnotation(Addressing.class);
    }
    if (addressing == null && serviceClass != null) {
        addressing = serviceClass.getAnnotation(Addressing.class);
    }
    if (addressing != null) {
        features.add(new AddressingFeature(addressing.enabled(), addressing.required(), addressing.responses()));
    }
    RespectBinding respectBinding = implInfo.getImplementorClass().getAnnotation(RespectBinding.class);
    if (respectBinding == null && serviceClass != null) {
        respectBinding = serviceClass.getAnnotation(RespectBinding.class);
    }
    if (respectBinding != null) {
        features.add(new RespectBindingFeature(respectBinding.enabled()));
    }
    if (!features.isEmpty()) {
        wsFeatures = features;
        if (setWsFeatures != null) {
            wsFeatures.addAll(setWsFeatures);
        }
    } else {
        wsFeatures = setWsFeatures;
    }
}
Also used : MTOM(javax.xml.ws.soap.MTOM) AddressingFeature(javax.xml.ws.soap.AddressingFeature) BindingType(javax.xml.ws.BindingType) MTOMFeature(javax.xml.ws.soap.MTOMFeature) RespectBindingFeature(javax.xml.ws.RespectBindingFeature) WebServiceFeature(javax.xml.ws.WebServiceFeature) ArrayList(java.util.ArrayList) RespectBinding(javax.xml.ws.RespectBinding) Addressing(javax.xml.ws.soap.Addressing)

Example 9 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSDiscoveryClient method getDispatchInternal.

private synchronized Dispatch<Object> getDispatchInternal(boolean addSeq, String action) {
    if (dispatch == null) {
        AddressingFeature f = new AddressingFeature(true, true);
        dispatch = getService().createDispatch(version.getServiceName(), getJAXBContext(), Service.Mode.PAYLOAD, f);
        dispatch.getRequestContext().put("thread.local.request.context", Boolean.TRUE);
        version.addVersionTransformer(dispatch);
    }
    addAddressing(dispatch, false, action);
    return dispatch;
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature)

Example 10 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class SymmetricBindingTest method testUsernameTokenSAML1Dispatch.

@org.junit.Test
public void testUsernameTokenSAML1Dispatch() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1Port");
    Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
    updateAddressPort(dispatch, test.getPort());
    // Setup STSClient
    STSClient stsClient = createDispatchSTSClient(bus);
    String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
    stsClient.setWsdlLocation(wsdlLocation);
    // Creating a DOMSource Object for the request
    DOMSource request = createDOMRequest();
    // Make a successful request
    Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
    client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
    if (test.isStreaming()) {
        client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    DOMSource response = dispatch.invoke(request);
    assertNotNull(response);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) DOMSource(javax.xml.transform.dom.DOMSource) STSClient(org.apache.cxf.ws.security.trust.STSClient) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Service(javax.xml.ws.Service) STSClient(org.apache.cxf.ws.security.trust.STSClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Aggregations

AddressingFeature (javax.xml.ws.soap.AddressingFeature)67 BindingProvider (javax.xml.ws.BindingProvider)35 URL (java.net.URL)18 QName (javax.xml.namespace.QName)13 Test (org.junit.Test)13 Service (javax.xml.ws.Service)8 ArrayList (java.util.ArrayList)7 WebServiceFeature (javax.xml.ws.WebServiceFeature)7 MTOMFeature (javax.xml.ws.soap.MTOMFeature)7 MAP (org.jboss.ws.api.addressing.MAP)5 RespectBindingFeature (javax.xml.ws.RespectBindingFeature)4 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)3 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)3 SoapFaultPortType (org.jboss.jbossts.xts.soapfault.SoapFaultPortType)3 CoordinationContextHandler (com.jboss.transaction.txinterop.webservices.handlers.CoordinationContextHandler)2 Sc007Service (com.jboss.transaction.wstf.webservices.sc007.generated.Sc007Service)2 WSBinding (com.sun.xml.ws.api.WSBinding)2 ServletAdapterList (com.sun.xml.ws.transport.http.servlet.ServletAdapterList)2 Closeable (java.io.Closeable)2 InputStream (java.io.InputStream)2