Search in sources :

Example 1 with WSDLFault

use of com.sun.xml.ws.api.model.wsdl.WSDLFault in project metro-jax-ws by eclipse-ee4j.

the class JavaMethodImpl method freeze.

/*package*/
void freeze(WSDLPort portType) {
    this.wsdlOperation = portType.getBinding().get(new QName(portType.getBinding().getPortType().getName().getNamespaceURI(), getOperationName()));
    // TODO: replace this with proper error handling
    if (wsdlOperation == null)
        throw new WebServiceException("Method " + seiMethod.getName() + " is exposed as WebMethod, but there is no corresponding wsdl operation with name " + operationName + " in the wsdl:portType" + portType.getBinding().getPortType().getName());
    // set the values from WSDLModel, if such annotations are not present or defaulted
    if (inputAction.equals("")) {
        inputAction = wsdlOperation.getOperation().getInput().getAction();
    } else if (!inputAction.equals(wsdlOperation.getOperation().getInput().getAction()))
        // TODO input action might be from @Action or WebMethod(action)
        LOGGER.warning("Input Action on WSDL operation " + wsdlOperation.getName().getLocalPart() + " and @Action on its associated Web Method " + seiMethod.getName() + " did not match and will cause problems in dispatching the requests");
    if (!mep.isOneWay()) {
        if (outputAction.equals(""))
            outputAction = wsdlOperation.getOperation().getOutput().getAction();
        for (CheckedExceptionImpl ce : exceptions) {
            if (ce.getFaultAction().equals("")) {
                QName detailQName = ce.getDetailType().tagName;
                WSDLFault wsdlfault = wsdlOperation.getOperation().getFault(detailQName);
                if (wsdlfault == null) {
                    // mismatch between wsdl model and SEI model, log a warning and use  SEI model for Action determination
                    LOGGER.warning("Mismatch between Java model and WSDL model found, For wsdl operation " + wsdlOperation.getName() + ",There is no matching wsdl fault with detail QName " + ce.getDetailType().tagName);
                    ce.setFaultAction(ce.getDefaultFaultAction());
                } else {
                    ce.setFaultAction(wsdlfault.getAction());
                }
            }
        }
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) WSDLFault(com.sun.xml.ws.api.model.wsdl.WSDLFault)

Example 2 with WSDLFault

use of com.sun.xml.ws.api.model.wsdl.WSDLFault in project metro-jax-ws by eclipse-ee4j.

the class WsaTubeHelper method getFaultAction.

String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
    String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
    if (action != null) {
        return action;
    }
    action = addVer.getDefaultFaultAction();
    if (wbo == null) {
        return action;
    }
    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }
        if (sm.getSOAPBody() == null) {
            return action;
        }
        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }
        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }
        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();
        WSDLOperation o = wbo.getOperation();
        WSDLFault fault = o.getFault(new QName(ns, name));
        if (fault == null) {
            return action;
        }
        action = fault.getAction();
        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) SOAPException(jakarta.xml.soap.SOAPException) WSDLOperation(com.sun.xml.ws.api.model.wsdl.WSDLOperation) SOAPMessage(jakarta.xml.soap.SOAPMessage) WSDLFault(com.sun.xml.ws.api.model.wsdl.WSDLFault) Detail(jakarta.xml.soap.Detail)

Example 3 with WSDLFault

use of com.sun.xml.ws.api.model.wsdl.WSDLFault in project metro-jax-ws by eclipse-ee4j.

the class WSDLParserTest method validateBinding.

private static void validateBinding(String wsdl, WSDLModel doc) {
    QName service = null;
    QName port = null;
    if (wsdl.equals("auctiontraq-doclit.wsdl")) {
        service = new QName("http://example.com/auctiontraq/wsdl/doclit", "AuctionTraqWSDLDoclitService");
        port = new QName("http://example.com/auctiontraq/wsdl/doclit", "AuctionTraqPort1");
    } else if (wsdl.equals("AddNumbers.wsdl")) {
        service = new QName("http://duke.org", "AddNumbersService");
        port = new QName("http://duke.org", "AddNumbersImplPort");
    } else if (wsdl.equals("bug.wsdl")) {
        service = new QName("http://server.hello/jaxws", "HelloImplService");
        port = new QName("http://server.hello/jaxws", "HelloImpl");
    } else if (wsdl.equals("HelloService.wsdl")) {
        service = new QName("http://helloservice.org/wsdl", "HelloService");
        port = new QName("http://helloservice.org/wsdl", "HelloPort");
    } else if (wsdl.equals("Issue500.wsdl")) {
        service = new QName("http://helloservice.org/wsdl", "HelloService");
        port = new QName("http://helloservice.org/wsdl", "HelloPort");
    } else if (wsdl.equals("hello_literal.wsdl")) {
        service = new QName("urn:test", "Hello");
        port = new QName("urn:test", "HelloPort");
    } else if (wsdl.equals("W2JRLR2011TestService.wsdl")) {
        service = new QName("http://w2jrlr2011testservice.org/W2JRLR2011TestService.wsdl", "W2JRLR2011TestService");
        port = new QName("http://w2jrlr2011testservice.org/W2JRLR2011TestService.wsdl", "W2JRLR2011TestPort");
    } else if (wsdl.equals("SimpleTest.wsdl")) {
        service = new QName("http://simpletestservice.org/wsdl", "SimpleTest");
        port = new QName("http://simpletestservice.org/wsdl", "SimpleEndpointPort");
    } else if (wsdl.equals("W2JDLR4002TestService.wsdl")) {
        service = new QName("http://w2jdlr4002testservice.org/W2JDLR4002TestService.wsdl", "W2JDLR4002TestService");
        port = new QName("http://w2jdlr4002testservice.org/W2JDLR4002TestService.wsdl", "W2JDLR4002TestPort");
    } else if (wsdl.equals("AddNumbers1.wsdl")) {
        service = new QName("http://example.com/", "AddNumbersService");
        port = new QName("http://example.com/", "AddNumbersPort");
    } else if (wsdl.equals("Neg_wsdl_extensions.wsdl")) {
        service = new QName("http://example.org", "AddNumbersService");
        port = new QName("http://example.org", "AddNumbersPort");
    } else if (wsdl.equals("jbi.wsdl")) {
        service = new QName("http://j2ee.netbeans.org/wsdl/newWSDL", "service1");
        port = new QName("http://j2ee.netbeans.org/wsdl/newWSDL", "port1");
        WSDLBoundPortType binding = doc.getBinding(service, port);
        assertNotNull(binding);
        WSDLBoundOperation op = binding.getOperation(null, "operation1");
        assertNull(op);
    } else if (wsdl.equals("policy.wsdl")) {
        service = new QName("http://wsit.test/", "FaultServiceService");
        port = new QName("http://wsit.test/", "FaultServicePort");
        WSDLBoundPortType binding = doc.getBinding(service, port);
        assertNotNull(binding);
        WSDLBoundOperation op = binding.get(new QName("http://wsit.test/", "echo"));
        assertNotNull(op);
        for (WSDLBoundFault bf : op.getFaults()) {
            if ((bf.getName().equals("EchoException"))) {
                WSDLFault fault = bf.getFault();
                assertNotNull(fault);
                assertEquals(fault.getName(), bf.getName());
            } else {
                assertEquals(bf.getName(), "Echo2Exception");
            }
        }
    }
    if (wsdl.equals("spews.wsdl")) {
        service = new QName("http://spews.pmg.net/", "SPEWS");
        port = new QName("http://spews.pmg.net/", "SPEWSSoap");
    }
    if (wsdl.equals("TestService.wsdl")) {
        service = new QName("http://service.test.policy.ws.xml.sun.com/", "TestServiceService");
        port = new QName("http://service.test.policy.ws.xml.sun.com/", "TestServicePort");
    } else {
        // no service port found, simply return
        return;
    }
    WSDLBoundPortType binding = doc.getBinding(service, port);
    if (binding == null) {
        System.out.println("[FAILED] No binding found for wsdl: " + wsdl + ", service: " + service + ", port: " + port + "!");
        assertTrue(false);
    }
    // test WSDLBoundPortType.getOperation()
    if (wsdl.equals("hello_literal.wsdl")) {
        WSDLBoundOperation op = binding.getOperation("urn:test:types", "Hello");
        assertTrue(op.getName().equals(new QName("urn:test", "hello")));
        assertTrue(op.getOperation().getInput().getName().equals("helloRequest"));
        assertTrue(op.getOperation().getOutput().getName().equals("helloResponse"));
        assertTrue(op.getOperation().getFaults().iterator().next().getName().equals("helloFault"));
        // check one way
        op = binding.getOperation("urn:test:types", "oneway");
        assertTrue(op.getName().equals(new QName("urn:test", "oneway")));
        assertTrue(op.getOperation().getInput().getName().equals("oneway"));
        assertTrue(op.getOperation().isOneWay());
        assertTrue(!op.getOperation().getFaults().iterator().hasNext());
        op = binding.getOperation("urn:test:types", "VoidTest");
        assertTrue(op.getName().equals(new QName("urn:test", "voidTest")));
        assertTrue(op.getOperation().getInput().getName().equals("voidInput"));
        assertTrue(op.getOperation().getOutput().getName().equals("voidOutput"));
    }
    if (wsdl.equals("AddNumbers1.wsdl")) {
        WSDLBoundOperation op = binding.getOperation("http://example.com/", "addNumbers");
        assertTrue(op.getName().equals(new QName("http://example.com/", "addNumbers")));
        assertTrue(op.getOperation().getInput().getName().equals("addNumbersRequest"));
        assertTrue(op.getOperation().getOutput().getName().equals("addNumbersResponse"));
        assertTrue(op.getOperation().getFaults().iterator().next().getName().equals("addNumbersFault"));
    }
    if (wsdl.equals("TestService.wsdl")) {
        WSDLBoundOperation op = binding.getOperation("http://service.test.policy.ws.xml.sun.com/", "echo");
        assertTrue(op.getName().equals(new QName("http://service.test.policy.ws.xml.sun.com/", "echo")));
    }
    if (wsdl.equals("Neg_wsdl_extensions.wsdl")) {
        WSDLPort wsdlPort = doc.getService(service).get(port);
        try {
            ((WSDLPortImpl) wsdlPort).areRequiredExtensionsUnderstood();
            assert (false);
        } catch (WebServiceException e) {
            System.out.println("Expected:");
            e.printStackTrace();
        }
    }
}
Also used : WSDLPortImpl(com.sun.xml.ws.model.wsdl.WSDLPortImpl) WSDLBoundOperation(com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation) WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) WSDLBoundFault(com.sun.xml.ws.api.model.wsdl.WSDLBoundFault) WSDLBoundPortType(com.sun.xml.ws.api.model.wsdl.WSDLBoundPortType) WSDLFault(com.sun.xml.ws.api.model.wsdl.WSDLFault) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Aggregations

WSDLFault (com.sun.xml.ws.api.model.wsdl.WSDLFault)3 WebServiceException (jakarta.xml.ws.WebServiceException)3 QName (javax.xml.namespace.QName)3 WSDLBoundFault (com.sun.xml.ws.api.model.wsdl.WSDLBoundFault)1 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 WSDLBoundPortType (com.sun.xml.ws.api.model.wsdl.WSDLBoundPortType)1 WSDLOperation (com.sun.xml.ws.api.model.wsdl.WSDLOperation)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 WSDLPortImpl (com.sun.xml.ws.model.wsdl.WSDLPortImpl)1 Detail (jakarta.xml.soap.Detail)1 SOAPException (jakarta.xml.soap.SOAPException)1 SOAPMessage (jakarta.xml.soap.SOAPMessage)1