Package javax.xml.soap

Examples of javax.xml.soap.SOAPMessage


            if (!SOAPMessageContext.class.isInstance(context)) {
                throw new SOAPException("SOAPMessageContext not available");
            }

            SOAPMessageContext soapContext = SOAPMessageContext.class.cast(context);
            SOAPMessage soapMessage = soapContext.getMessage();

            SOAPFault fault = soapMessage.getSOAPBody().getFault();
            DataReader<SOAPFault> reader = callback.createReader(SOAPFault.class);

            Object faultObj = null;
            if (null != reader) {
                LOG.log(Level.INFO, "SOAP_FAULT_NO_READER");
View Full Code Here


        if (!SOAPMessageContext.class.isInstance(context)) {
            throw SOAPFaultExHelper.createSOAPFaultEx(soapFactory, faultCode,
                                                      "SOAPMessageContext not available");
        }
        SOAPMessageContext soapCtx = SOAPMessageContext.class.cast(context);
        SOAPMessage soapMessage;
        QName code = faultCode;
        try {
            MimeHeaders headers = new MimeHeaders();
            Map<String, List<String>> httpHeaders;
           
            if (isServer) {
                httpHeaders = (Map<String, List<String>>)soapCtx.get(MessageContext.HTTP_REQUEST_HEADERS);
            } else {
                httpHeaders = (Map<String, List<String>>)soapCtx.get(MessageContext.HTTP_RESPONSE_HEADERS);
            }
            if (httpHeaders != null) {
                for (String key : httpHeaders.keySet()) {
                    if (null != key) {
                        List<String> values = httpHeaders.get(key);
                        for (String value : values) {
                            headers.addHeader(key, value);
                        }
                    }
                }
            }

            soapMessage = msgFactory.createMessage(headers, inCtx.getInputStream());
            //Test if it is a valid SOAP 1.1 Message
            code = FAULTCODE_VERSIONMISMATCH;
            soapMessage.getSOAPPart().getEnvelope();
        } catch (SOAPException se) {
            LOG.log(Level.SEVERE, "SOAP_PARSING_FAILURE_MSG", se);
            throw SOAPFaultExHelper.createSOAPFaultEx(soapFactory, code, se);
        }
       
View Full Code Here

        soapCtx.setMessage(soapMessage);       
    }

    public boolean hasFault(MessageContext msgContext) {
        boolean hasFault = false;
        SOAPMessage msg = ((SOAPMessageContext)msgContext).getMessage();
        assert msg != null;
        try {
            hasFault = msg.getSOAPBody().hasFault();
        } catch (SOAPException se) {
            LOG.log(Level.SEVERE, "SOAP_UNMARSHALLING_FAILURE_MSG", se);
            throw new ProtocolException(se);
        }
        return hasFault;
View Full Code Here

        return hasFault;
    }

    public void updateMessageContext(MessageContext msgContext) {
        if (msgContext instanceof SOAPMessageContext) {
            SOAPMessage msg = ((SOAPMessageContext)msgContext).getMessage();
            try {
                updateHeaders(msgContext, msg);
            } catch (SOAPException se) {
                throw SOAPFaultExHelper.createSOAPFaultEx(soapFactory, faultCode, se);
            }
View Full Code Here

        return soapFactory;
    }

    private SOAPMessage initSOAPMessage() throws SOAPException {

        SOAPMessage msg = msgFactory.createMessage();
        msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
        msg.getSOAPPart().getEnvelope().addNamespaceDeclaration(W3CConstants.NP_SCHEMA_XSD,
                                                                W3CConstants.NU_SCHEMA_XSD);
        msg.getSOAPPart().getEnvelope().addNamespaceDeclaration(W3CConstants.NP_SCHEMA_XSI,
                                                                W3CConstants.NU_SCHEMA_XSI);

        return msg;
    }
View Full Code Here

        put(SOAP_MESSAGE, soapMsg);
        setScope(SOAP_MESSAGE, MessageContext.Scope.HANDLER);       
    }

    public Object[] getHeaders(QName headerName, JAXBContext jaxbContext, boolean allRoles) {
        SOAPMessage msg = getMessage();
        assert msg != null;

        List<Object> headerList  = new ArrayList<Object>();

        SOAPHeader header = null;
        try {
            header = msg.getSOAPHeader();
        } catch (SOAPException se) {
            throw new WebServiceException("Could not get the SOAPHeader node", se);
        }
       
        if (header == null) {
View Full Code Here

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        try {
            MessageFactory factory = MessageFactory.newInstance();
            SOAPMessage soapReq = factory.createMessage();
            soapReq.getSOAPPart().setContent(request);
   
            System.out.println("Incoming Client Request as a DOMSource data in MESSAGE Mode");
            soapReq.writeTo(System.out);
            System.out.println("\n");
   
            InputStream is = getClass().getResourceAsStream("GreetMeDocLiteralResp2.xml");
            SOAPMessage greetMeResponse =  factory.createMessage(null, is);
            is.close();

            response.setNode(greetMeResponse.getSOAPPart());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return response;
    }
View Full Code Here

    public GreeterSoapMessageProvider() {
        //Complete
    }
   
    public SOAPMessage invoke(SOAPMessage request) {
        SOAPMessage response = null;       
        try {
            MessageFactory factory = MessageFactory.newInstance();           
            InputStream is = getClass().getResourceAsStream("GreetMeDocLiteralResp1.xml");
            response =  factory.createMessage(null, is);
            is.close();
View Full Code Here

            out.println("\nOutbound message:");
        } else {
            out.println("\nInbound message:");
        }

        SOAPMessage message = smc.getMessage();
        try {
            message.writeTo(out);
            out.println();
        } catch (Exception e) {
            out.println("Exception in handler: " + e);
        }
    }
View Full Code Here

        QName serviceName1 = new QName(ns, "SOAPService1");
        QName portName1 = new QName(ns, "SoapPort1");

        SOAPService1 service1 = new SOAPService1(wsdlURL, serviceName1);
        InputStream is1 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq1.xml");
        SOAPMessage soapReq1 = factory.createMessage(null, is1);

        Dispatch<SOAPMessage> dispSOAPMsg = service1.createDispatch(portName1,
                                                                    SOAPMessage.class, Mode.MESSAGE);

        System.out.println("Invoking server through Dispatch interface using SOAPMessage");
        SOAPMessage soapResp = dispSOAPMsg.invoke(soapReq1);
        System.out.println("Response from server: " + soapResp.getSOAPBody().getTextContent());

        QName serviceName3 = new QName(ns, "SOAPService3");
        QName portName3 = new QName(ns, "SoapPort3");

        SOAPService3 service3 = new SOAPService3(wsdlURL, serviceName3);
        InputStream is3 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq3.xml");
        SOAPMessage soapReq3 = MessageFactory.newInstance().createMessage(null, is3);
        DOMSource domReqPayload = new DOMSource(soapReq3.getSOAPBody().extractContentAsDocument());

        Dispatch<DOMSource> dispDOMSrcPayload = service3.createDispatch(portName3,
                                                                        DOMSource.class, Mode.PAYLOAD);
        System.out.println("Invoking server through Dispatch interface using DOMSource in PAYLOAD Mode");
        DOMSource domRespPayload = dispDOMSrcPayload.invoke(domReqPayload);
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.