Search in sources :

Example 46 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.

the class ClientServlet3 method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    boolean result = false;
    try {
        log.info("service = " + service);
        Hello hello = service.getHelloPort();
        SOAPBinding binding = (SOAPBinding) ((BindingProvider) hello).getBinding();
        if ("true".equals(req.getParameter("mtom"))) {
            log.info("mtom enabled = " + binding.isMTOMEnabled());
            if (!binding.isMTOMEnabled()) {
                throw new Exception("Expected mtom enabled because of @MTOM annotation");
            }
        }
        result = hello.getMessageContextTest();
        log.info("result = " + result);
    } catch (Exception e) {
        log.error("Error while invoking service!", e);
        throw new ServletException(e);
    }
    resp.getWriter().print(result);
}
Also used : ServletException(javax.servlet.ServletException) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 47 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.

the class MTOMFeatureTestCase method addMTOMCheckHandler.

private static void addMTOMCheckHandler(MTOMEndpoint port) {
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(binding.getHandlerChain());
    handlerChain.add(new MTOMCheckClientHandler());
    binding.setHandlerChain(handlerChain);
}
Also used : ArrayList(java.util.ArrayList) SOAPBinding(javax.xml.ws.soap.SOAPBinding) DataHandler(javax.activation.DataHandler) Handler(javax.xml.ws.handler.Handler)

Example 48 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.

the class EJBClient method echo.

public String echo(String inStr) throws RemoteException {
    log.info("echo: " + inStr);
    List<Endpoint> ports = new ArrayList<Endpoint>(2);
    try {
        InitialContext iniCtx = new InitialContext();
        ports.add(((Service) iniCtx.lookup("java:comp/env/service1")).getPort(Endpoint.class));
        ports.add(((EndpointService) iniCtx.lookup("java:comp/env/service2")).getEndpointPort());
    } catch (Exception ex) {
        throw new WebServiceException(ex);
    }
    for (int i = 0; i < ports.size(); i++) {
        Endpoint port = ports.get(i);
        BindingProvider bp = (BindingProvider) port;
        @SuppressWarnings("unused") boolean mtomEnabled = ((SOAPBinding) bp.getBinding()).isMTOMEnabled();
        // boolean expectedSetting = (i==0) ? false : true;
        // if(mtomEnabled != expectedSetting)
        // throw new WebServiceException("MTOM settings (enabled="+expectedSetting+") not overridden through service-ref" );
        String outStr = port.echo(inStr);
        if (inStr.equals(outStr) == false)
            throw new WebServiceException("Invalid echo return: " + inStr);
    }
    return inStr;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) InitialContext(javax.naming.InitialContext) WebServiceException(javax.xml.ws.WebServiceException) RemoteException(java.rmi.RemoteException)

Example 49 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.

the class JBWS2419TestCase method testSOAP11ClientAccess.

@Test
@RunAsClient
public void testSOAP11ClientAccess() throws Exception {
    URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP11EndpointBeanService");
    Service service = Service.create(wsdlURL, qname);
    SOAP11Endpoint port = service.getPort(SOAP11Endpoint.class);
    BindingProvider provider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(provider.getBinding().getHandlerChain());
    handlerChain.add(new SOAP11ClientHandler());
    provider.getBinding().setHandlerChain(handlerChain);
    ((SOAPBinding) provider.getBinding()).setMTOMEnabled(true);
    DataHandler response = port.namespace(new DataHandler("Jimbo", "text/plain"));
    Object messg = getContent(response);
    assertEquals("Hello Jimbo", messg);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) DataHandler(javax.activation.DataHandler) Handler(javax.xml.ws.handler.Handler) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 50 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.

the class JBWS2419TestCase method testSOAP12ClientAccess.

@Test
@RunAsClient
public void testSOAP12ClientAccess() throws Exception {
    URL wsdlURL = new URL(baseURL + "/soap12?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP12EndpointBeanService");
    Service service = Service.create(wsdlURL, qname);
    SOAP12Endpoint port = service.getPort(SOAP12Endpoint.class);
    BindingProvider provider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(provider.getBinding().getHandlerChain());
    handlerChain.add(new SOAP12ClientHandler());
    provider.getBinding().setHandlerChain(handlerChain);
    ((SOAPBinding) provider.getBinding()).setMTOMEnabled(true);
    DataHandler response = port.namespace(new DataHandler("Jimbo", "text/plain"));
    Object messg = getContent(response);
    assertEquals("Hello Jimbo", messg);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) DataHandler(javax.activation.DataHandler) Handler(javax.xml.ws.handler.Handler) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

SOAPBinding (javax.xml.ws.soap.SOAPBinding)52 URL (java.net.URL)20 BindingProvider (javax.xml.ws.BindingProvider)20 Test (org.junit.Test)20 QName (javax.xml.namespace.QName)19 Service (javax.xml.ws.Service)15 DataHandler (javax.activation.DataHandler)14 WebServiceException (javax.xml.ws.WebServiceException)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 JBossWSTest (org.jboss.wsf.test.JBossWSTest)7 ArrayList (java.util.ArrayList)6 Holder (javax.xml.ws.Holder)6 Image (java.awt.Image)5 IOException (java.io.IOException)5 Binding (javax.xml.ws.Binding)5 File (java.io.File)4 Before (org.junit.Before)4 FileDataSource (javax.activation.FileDataSource)3 Handler (javax.xml.ws.handler.Handler)3 MTOMFeature (javax.xml.ws.soap.MTOMFeature)3