Package javax.xml.soap

Examples of javax.xml.soap.SOAPBody


            msg.put(WSHandlerConstants.RECV_RESULTS, results);
        }
        WSHandlerResult rResult = new WSHandlerResult(actor, wsResult);
        results.add(0, rResult);

        SOAPBody body = doc.getSOAPBody();

        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new DOMSource(body));
        // advance just past body
        int evt = reader.next();
        int i = 0;
View Full Code Here


            msg.put(WSHandlerConstants.RECV_RESULTS, results);
        }
        WSHandlerResult rResult = new WSHandlerResult(actor, wsResult);
        results.add(0, rResult);

        SOAPBody body = doc.getSOAPBody();

        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new DOMSource(body));
        // advance just past body
        int evt = reader.next();
        int i = 0;
View Full Code Here

        try {
            SOAPMessage msg = sm.getMessage();
            if (msg == null) {
                return null;
            }
            SOAPBody body = msg.getSOAPBody();
            if (body == null) {
                return null;
            }
            org.w3c.dom.Node nd = body.getFirstChild();
            while (nd != null && !(nd instanceof org.w3c.dom.Element)) {
                nd = nd.getNextSibling();
            }
            if (nd != null) {
                return new QName(nd.getNamespaceURI(), nd.getLocalName());
View Full Code Here

            .getInputStream(), originalEmptyOs.getInputStream()));

        // Verify SOAPMessage
        SOAPMessage resultedMessage = message.getContent(SOAPMessage.class);
        assertNotNull(resultedMessage);
        SOAPBody bodyNew = resultedMessage.getSOAPBody();
        Iterator itNew = bodyNew.getChildElements(new QName("http://apache.org/hello_world_rpclit",
                                                            "sendReceiveDataResponse"));
        SOAPBodyElement bodyElementNew = (SOAPBodyElement)itNew.next();
        Iterator outIt = bodyElementNew
            .getChildElements(new QName("http://apache.org/hello_world_rpclit/types", "out"));
        Element outElement = (SOAPElement)outIt.next();
View Full Code Here

        li.handleMessage(message);
        control.verify();

        // Verify SOAPMessage
        SOAPMessage soapMessageNew = message.getContent(SOAPMessage.class);
        SOAPBody bodyNew = soapMessageNew.getSOAPBody();
        Iterator itNew = bodyNew.getChildElements();
        SOAPBodyElement bodyElementNew = (SOAPBodyElement)itNew.next();
        assertEquals("sendReceiveData", bodyElementNew.getLocalName());

        // Verify the XMLStreamReader
        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
View Full Code Here

      SOAPMessage soapMsg = MessageFactory.newInstance(  ).createMessage(  );

      SOAPHeader  soapHeader = soapMsg.getSOAPHeader(  );

      //TODO !!! set the wsa headers
      SOAPBody soapBody = soapMsg.getSOAPBody(  );

      //TODO doubt this will work...but lets give it a try using a Document type "notifyDoc"
      soapBody.addDocument( dom );
      return soapMsg;
   }
View Full Code Here

               ByteArrayOutputStream bs = new ByteArrayOutputStream();
               soapReq.writeTo(bs);
               log.debug("Request received::"+bs.toString());
            }

            SOAPBody soapReqBody = soapReq.getSOAPBody();
            Iterator it = soapReqBody.getChildElements();
            Element uddiReq = null;
            while (uddiReq == null && it.hasNext())
            {
               Object current = it.next();
               if (current instanceof Element)
               {
                  uddiReq = (Element)current;
               }
            }
           
            if (uddiReq == null)
                throw new FatalErrorException("A UDDI request was not " +
                        "found in the SOAP message.");

            String function = uddiReq.getLocalName();
            if ((function == null) || (function.trim().length() == 0))
                throw new FatalErrorException("The name of the UDDI request " +
                        "could not be identified.");
            IHandler requestHandler = maker.lookup(function);
            if (requestHandler == null)
                throw new UnsupportedException("The UDDI request " +
                        "type specified is unknown: " + function);

            String generic = uddiReq.getAttribute("generic");
            if (generic == null)
                throw new FatalErrorException("A UDDI generic attribute " +
                        "value was not found for UDDI request: " + function + " (The " +
                        "'generic' attribute must be present)");
            else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))
                throw new UnsupportedException("Currently only UDDI v2 " +
                        "requests are supported. The generic attribute value " +
                        "received was: " + generic);

            // Unmarshal the raw xml into the appropriate jUDDI
            // request object.

            RegistryObject uddiReqObj = requestHandler.unmarshal(uddiReq);
            if(uddiReqObj == null)
               throw new FatalErrorException("Uddi Request is null");

            // Grab a reference to the shared jUDDI registry
            // instance (make sure it's running) and execute the
            // requested UDDI function.

            RegistryObject uddiResObj = null;
            RegistryEngine registry = RegistryServlet.getRegistry();
            if ((registry != null) && (registry.isAvailable()))
                uddiResObj = registry.execute(uddiReqObj);
            else
                throw new BusyException("The Registry is currently unavailable.");

            // Lookup the appropriate response handler which will
            // be used to marshal the UDDI object into the appropriate
            // xml format.

            IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
            if (responseHandler == null)
                throw new FatalErrorException("The response object " +
                        "type is unknown: " + uddiResObj.getClass().getName());

            // Create a new 'temp' XML element to use as a container
            // in which to marshal the UDDI response data into.

            DocumentBuilder docBuilder = getDocumentBuilder();
            Document document = docBuilder.newDocument();
            Element element = document.createElement("temp");

            // Lookup the appropriate response handler and marshal
            // the juddi object into the appropriate xml format (we
            // only support UDDI v2.0 at this time).  Attach the
            // results to the body of the SOAP response.

            responseHandler.marshal(uddiResObj, element);
            log.debug("Response that will be sent:");
            log.debug(XMLUtils.toString((Element) element.getFirstChild()));

            // Grab a reference to the 'temp' element's
            // only child here (this has the effect of
            // discarding the temp element) and append
            // this child to the soap response body

            /*document.appendChild(element.getFirstChild());
            soapRes.getSOAPBody().addDocument(document);*/
            Element el = (Element) element.getFirstChild();
            soapRes = this.createSOAPMessage(el);
        } catch (Exception ex) // Catch ALL exceptions
        {
            // SOAP Fault values
            String faultCode = null;
            String faultString = null;
            String faultActor = null;

            // UDDI DispositionReport values
            String errno = null;
            String errCode = null;
            String errMsg = null;

            if (ex instanceof RegistryException)
            {

                log.error("RegistryException::",ex);

                RegistryException rex = (RegistryException) ex;

                faultCode = rex.getFaultCode()// SOAP Fault faultCode
                faultString = rex.getFaultString()// SOAP Fault faultString
                faultActor = rex.getFaultActor()// SOAP Fault faultActor

                DispositionReport dispRpt = rex.getDispositionReport();
                if (dispRpt != null)
                {
                    Result result = null;
                    ErrInfo errInfo = null;

                    Vector results = dispRpt.getResultVector();
                    if ((results != null) && (!results.isEmpty()))
                        result = (Result) results.elementAt(0);

                    if (result != null)
                    {
                        errno = String.valueOf(result.getErrno())// UDDI Result errno
                        errInfo = result.getErrInfo();

                        if (errInfo != null)
                        {
                            errCode = errInfo.getErrCode()// UDDI ErrInfo errCode
                            errMsg = errInfo.getErrMsg()// UDDI ErrInfo errMsg
                        }
                    }
                }
            } else
            {

                log.error(ex.getMessage(), ex);

                faultCode = "Server";
                faultString = ex.getMessage();
                faultActor = null;


                errno = String.valueOf(Result.E_FATAL_ERROR);
                errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
                errMsg = Result.lookupErrText(Result.E_FATAL_ERROR);
            }

            try
            {
                SOAPBody soapResBody = soapRes.getSOAPBody();
                SOAPFault soapFault = soapResBody.addFault();
                if(faultCode == null)
                   faultCode = "Unavailable";
               
                if (faultCode.contains(":") == false)
                {
View Full Code Here

       SOAPFactory factory = SOAPFactory.newInstance();
      
       SOAPMessage message = msgFactory.createMessage();
       message.getSOAPHeader().detachNode();
       SOAPPart soapPart = message.getSOAPPart();
       SOAPBody soapBody = soapPart.getEnvelope().getBody();
       //Create the outer body element
       String uddins = IRegistry.UDDI_V2_NAMESPACE;
       Name bodyName = factory.createName(elem.getNodeName(), prefix, uddins);
       SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
       bodyElement.addNamespaceDeclaration(prefix,uddins);     
       appendAttributes(bodyElement, elem.getAttributes(), factory);
       appendElements(bodyElement,elem.getChildNodes(), factory);
       return message;
    }
View Full Code Here

    // The rest endpoint is working ok
    public void testCxfSoapSessionLookup() throws Exception {
        
       
        SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
        SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
        QName payloadName = new QName( "http://soap.jax.drools.org",
                                       "execute",
                                       "ns1" );

        body.addBodyElement( payloadName );

        String cmd = "";
        cmd += "<batch-execution lookup=\"ksession1\">\n";
        cmd += "  <insert out-identifier=\"salaboy\" disconnected=\"true\">\n";
        cmd += "      <org.drools.springframework.Person2>\n";
        cmd += "         <name>salaboy</name>\n";
        cmd += "         <age>27</age>\n";
        cmd += "      </org.drools.springframework.Person2>\n";
        cmd += "   </insert>\n";
        cmd += "   <fire-all-rules/>\n";
        cmd += "</batch-execution>\n";

        body.addTextNode( cmd );

        Object object = this.context.createProducerTemplate().requestBody( "direct://http",
                                                                           soapMessage );

        OutputStream out = new ByteArrayOutputStream();
        out = new ByteArrayOutputStream();
        soapMessage = (SOAPMessage) object;
        soapMessage.writeTo( out );
        String response = out.toString();
        assertTrue( response.contains( "fact-handle identifier=\"salaboy\"" ) );
       
       
       
         SOAPMessage soapMessage2 = MessageFactory.newInstance().createMessage();
        SOAPBody body2 = soapMessage.getSOAPPart().getEnvelope().getBody();
        QName payloadName2 = new QName( "http://soap.jax.drools.org",
                                       "execute",
                                       "ns1" );

        body2.addBodyElement( payloadName2);

        String cmd2 = "";
        cmd2 += "<batch-execution lookup=\"ksession2\">\n";
        cmd2 += "  <insert out-identifier=\"salaboy\" disconnected=\"true\">\n";
        cmd2 += "      <org.drools.springframework.Person3>\n";
        cmd2 += "         <name>salaboy</name>\n";
        cmd2 += "         <age>27</age>\n";
        cmd2 += "      </org.drools.springframework.Person3>\n";
        cmd2 += "   </insert>\n";
        cmd2 += "   <fire-all-rules/>\n";
        cmd2 += "</batch-execution>\n";

        body2.addTextNode( cmd2 );

        Object object2 = this.context.createProducerTemplate().requestBody( "direct://http",
                                                                           soapMessage2 );

        OutputStream out2 = new ByteArrayOutputStream();
View Full Code Here

    @Test
    public void test1() throws Exception {

        SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
        SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
        QName payloadName = new QName( "http://soap.jax.drools.org",
                                       "execute",
                                       "ns1" );

        body.addBodyElement( payloadName );

        String cmd = "";
        cmd += "<batch-execution lookup=\"ksession1\">\n";
        cmd += "  <insert out-identifier=\"salaboy\" disconnected=\"true\">\n";
        cmd += "      <org.drools.pipeline.camel.Person>\n";
        cmd += "         <name>salaboy</name>\n";
        cmd += "         <age>27</age>\n";
        cmd += "      </org.drools.pipeline.camel.Person>\n";
        cmd += "   </insert>\n";
        cmd += "   <fire-all-rules/>\n";
        cmd += "</batch-execution>\n";

        body.addTextNode( cmd );

        Object object = this.context.createProducerTemplate().requestBody( "direct://http",
                                                                           soapMessage );

        OutputStream out = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPBody

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.