Search in sources :

Example 41 with AddressingFeature

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

the class DispatchClientServerTest method testJAXBObjectPAYLOADFromEPR.

@Test
public void testJAXBObjectPAYLOADFromEPR() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
    builder.serviceName(SERVICE_NAME);
    builder.endpointName(PORT_NAME);
    W3CEndpointReference w3cEpr = builder.build();
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(w3cEpr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
    doJAXBPayload(disp);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) AddressingFeature(javax.xml.ws.soap.AddressingFeature) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) JAXBContext(javax.xml.bind.JAXBContext) URL(java.net.URL) Test(org.junit.Test)

Example 42 with AddressingFeature

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

the class JMSClientServerTest method testOneWayQueueConnection.

@Test
public void testOneWayQueueConnection() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldOneWayQueueService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldOneWayQueuePort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldOneWayQueueService service = new HelloWorldOneWayQueueService(wsdl, serviceName);
    HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class, new AddressingFeature(true, true));
    for (int idx = 0; idx < 5; idx++) {
        greeter.greetMeOneWay("JMS:Queue:Milestone-" + idx);
    }
    // Give some time to complete one-way calls.
    Thread.sleep(100L);
    ((java.io.Closeable) greeter).close();
}
Also used : HelloWorldOneWayPort(org.apache.cxf.hello_world_jms.HelloWorldOneWayPort) AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) HelloWorldOneWayQueueService(org.apache.cxf.hello_world_jms.HelloWorldOneWayQueueService) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 43 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project Payara by payara.

the class EjbRuntimeEndpointInfo method prepareInvocation.

public Object prepareInvocation(boolean doPreInvoke) throws Exception {
    ComponentInvocation inv = null;
    AdapterInvocationInfo adapterInvInfo = new AdapterInvocationInfo();
    // init'ing jaxws is done here - this sequence is important
    if (adapter == null) {
        synchronized (this) {
            if (adapter == null) {
                try {
                    // Set webservice context here
                    // If the endpoint has a WebServiceContext with @Resource then
                    // that has to be used
                    EjbDescriptor ejbDesc = endpoint.getEjbComponentImpl();
                    Iterator<ResourceReferenceDescriptor> it = ejbDesc.getResourceReferenceDescriptors().iterator();
                    while (it.hasNext()) {
                        ResourceReferenceDescriptor r = it.next();
                        if (r.isWebServiceContext()) {
                            Iterator<InjectionTarget> iter = r.getInjectionTargets().iterator();
                            boolean matchingClassFound = false;
                            while (iter.hasNext()) {
                                InjectionTarget target = iter.next();
                                if (ejbDesc.getEjbClassName().equals(target.getClassName())) {
                                    matchingClassFound = true;
                                    break;
                                }
                            }
                            if (!matchingClassFound) {
                                continue;
                            }
                            try {
                                javax.naming.InitialContext ic = new javax.naming.InitialContext();
                                wsCtxt = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
                            } catch (Throwable t) {
                                if (logger.isLoggable(Level.FINE)) {
                                    logger.log(Level.FINE, LogUtils.ERROR_EREI, t.getCause());
                                }
                            }
                        }
                    }
                    if (wsCtxt == null) {
                        wsCtxt = new WebServiceContextImpl();
                    }
                } catch (Throwable t) {
                    LogHelper.log(logger, Level.SEVERE, LogUtils.CANNOT_INITIALIZE, t, endpoint.getName());
                    return null;
                }
            }
        }
    }
    if (doPreInvoke) {
        inv = container.startInvocation();
        adapterInvInfo.setInv(inv);
    }
    // Now process handlers and init jaxws RI
    synchronized (this) {
        if (!handlersConfigured && doPreInvoke) {
            try {
                WsUtil wsu = new WsUtil();
                String implClassName = endpoint.getEjbComponentImpl().getEjbClassName();
                Class clazz = container.getEndpointClassLoader().loadClass(implClassName);
                // Get the proper binding using BindingID
                String givenBinding = endpoint.getProtocolBinding();
                // Get list of all wsdls and schema
                SDDocumentSource primaryWsdl = null;
                Collection docs = null;
                if (endpoint.getWebService().hasWsdlFile()) {
                    WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
                    ApplicationRegistry appRegistry = wscImpl.getApplicationRegistry();
                    ApplicationInfo appInfo = appRegistry.get(endpoint.getBundleDescriptor().getApplication().getRegistrationName());
                    URI deployedDir = appInfo.getSource().getURI();
                    URL pkgedWsdl;
                    if (deployedDir != null) {
                        if (endpoint.getBundleDescriptor().getApplication().isVirtual()) {
                            pkgedWsdl = deployedDir.resolve(endpoint.getWebService().getWsdlFileUri()).toURL();
                        } else {
                            String moduleUri1 = endpoint.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
                            // Fix for issue 7024099
                            // Only replace the last "." with "_" for moduleDescriptor's archive uri
                            String moduleUri = FileUtils.makeFriendlyFilenameExtension(moduleUri1);
                            pkgedWsdl = deployedDir.resolve(moduleUri + "/" + endpoint.getWebService().getWsdlFileUri()).toURL();
                        }
                    } else {
                        pkgedWsdl = endpoint.getWebService().getWsdlFileUrl();
                    }
                    if (pkgedWsdl != null) {
                        primaryWsdl = SDDocumentSource.create(pkgedWsdl);
                        docs = wsu.getWsdlsAndSchemas(pkgedWsdl);
                    }
                }
                // Create a Container to pass ServletContext and also inserting the pipe
                JAXWSContainer container = new JAXWSContainer(null, endpoint);
                // Get catalog info
                java.net.URL catalogURL = clazz.getResource('/' + endpoint.getBundleDescriptor().getDeploymentDescriptorDir() + File.separator + "jax-ws-catalog.xml");
                // Create Binding and set service side handlers on this binding
                boolean mtomEnabled = wsu.getMtom(endpoint);
                WSBinding binding = null;
                ArrayList<WebServiceFeature> wsFeatures = new ArrayList<WebServiceFeature>();
                // Only if MTOm is enabled create the Binding with the MTOMFeature
                if (mtomEnabled) {
                    int mtomThreshold = endpoint.getMtomThreshold() != null ? Integer.parseInt(endpoint.getMtomThreshold()) : 0;
                    MTOMFeature mtom = new MTOMFeature(true, mtomThreshold);
                    wsFeatures.add(mtom);
                }
                Addressing addressing = endpoint.getAddressing();
                if (endpoint.getAddressing() != null) {
                    AddressingFeature addressingFeature = new AddressingFeature(addressing.isEnabled(), addressing.isRequired(), getResponse(addressing.getResponses()));
                    wsFeatures.add(addressingFeature);
                }
                if (wsFeatures.size() > 0) {
                    binding = BindingID.parse(givenBinding).createBinding(wsFeatures.toArray(new WebServiceFeature[wsFeatures.size()]));
                } else {
                    binding = BindingID.parse(givenBinding).createBinding();
                }
                wsu.configureJAXWSServiceHandlers(endpoint, endpoint.getProtocolBinding(), binding);
                // See if it is configured with JAX-WS extension InstanceResolver annotation like
                // @com.sun.xml.ws.developer.servlet.HttpSessionScope or @com.sun.xml.ws.developer.Stateful
                // #GLASSFISH-21081
                InstanceResolver ir = InstanceResolver.createFromInstanceResolverAnnotation(clazz);
                // TODO - Implement 109 StatefulInstanceResolver ??
                if (ir == null) {
                    // use our own InstanceResolver that does not call @PostConstuct method before
                    // @Resource injections have happened.
                    ir = new InstanceResolverImpl(clazz);
                }
                // Create the jaxws2.1 invoker and use this
                Invoker invoker = ir.createInvoker();
                WSEndpoint wsep = WSEndpoint.create(// The endpoint class
                clazz, // we do not want JAXWS to process @HandlerChain
                false, // the invoker
                new EjbInvokerImpl(clazz, invoker, webServiceEndpointServant, wsCtxt), // the service QName
                endpoint.getServiceName(), // the port
                endpoint.getWsdlPort(), container, // Derive binding
                binding, // primary WSDL
                primaryWsdl, // Collection of imported WSDLs and schema
                docs, catalogURL);
                String uri = endpoint.getEndpointAddressUri();
                String urlPattern = uri.startsWith("/") ? uri : "/" + uri;
                // All set; Create the adapter
                if (adapterList == null) {
                    adapterList = new ServletAdapterList();
                }
                adapter = adapterList.createAdapter(endpoint.getName(), urlPattern, wsep);
                handlersConfigured = true;
            } catch (Throwable t) {
                LogHelper.log(logger, Level.SEVERE, LogUtils.CANNOT_INITIALIZE, t, endpoint.getName());
                adapter = null;
            }
        }
    }
    // set it using this method
    synchronized (this) {
        addWSContextInfo(wsCtxt);
        if (inv != null && inv instanceof EJBInvocation) {
            EJBInvocation ejbInv = (EJBInvocation) inv;
            ejbInv.setWebServiceContext(wsCtxt);
        }
    }
    adapterInvInfo.setAdapter(adapter);
    return adapterInvInfo;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) URL(java.net.URL) InstanceResolver(com.sun.xml.ws.api.server.InstanceResolver) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ArrayList(java.util.ArrayList) URI(java.net.URI) URL(java.net.URL) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) Invoker(com.sun.xml.ws.api.server.Invoker) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) ServletAdapterList(com.sun.xml.ws.transport.http.servlet.ServletAdapterList) MTOMFeature(javax.xml.ws.soap.MTOMFeature) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) WebServiceFeature(javax.xml.ws.WebServiceFeature) Collection(java.util.Collection) EJBInvocation(org.glassfish.ejb.api.EJBInvocation)

Example 44 with AddressingFeature

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

the class WSADisableTest method testDiaptchWithWsaDisable.

@Test
public void testDiaptchWithWsaDisable() throws Exception {
    QName port = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
    Dispatch<SOAPMessage> disptch = getService().createDispatch(port, SOAPMessage.class, javax.xml.ws.Service.Mode.MESSAGE, new AddressingFeature(false));
    ((BindingProvider) disptch).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    InputStream is = getClass().getResourceAsStream("resources/AddNumbersDispatchReq.xml");
    SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is);
    assertNotNull(soapReqMsg);
    try {
        disptch.invoke(soapReqMsg);
        fail("The MAPcodec ate the SOAPFaultException");
    } catch (javax.xml.ws.soap.SOAPFaultException e) {
    // expected
    }
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) SOAPMessage(javax.xml.soap.SOAPMessage) Test(org.junit.Test)

Example 45 with AddressingFeature

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

the class WSAFaultToClientServerTest method getTwoWayPort.

private AddNumbersPortType getTwoWayPort() throws Exception {
    URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
    assertNotNull("WSDL is null", wsdl);
    QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersService");
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull("Service is null ", service);
    return service.getAddNumbersPort(new AddressingFeature());
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) 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