Package javax.xml.soap

Examples of javax.xml.soap.SOAPBody


             * SOAPFault with the exception thrown from HandleFault so that the
             * exception can be dispatched.
             */
            try {
                SOAPMessage originalMsg = message.getContent(SOAPMessage.class);
                SOAPBody body = originalMsg.getSOAPBody();
                body.removeContents();

                SOAPFault soapFault = body.addFault();

                if (exception instanceof SOAPFaultException) {
                    SOAPFaultException sf = (SOAPFaultException)exception;
                    soapFault.setFaultString(sf.getFault().getFaultString());
                    soapFault.setFaultCode(sf.getFault().getFaultCodeAsQName());
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

      // of the SOAP Request message. If a UDDI request
      // message does not exist within the SOAP Body
      // then throw a FatalErrorException and indicate
      // that this is a Client-side (consumer) error.

      SOAPBody soapReqBody = soapReq.getSOAPBody();
      Element uddiReq = null;
      Iterator itrChildElements = soapReqBody.getChildElements();
      while (itrChildElements.hasNext()) {
        Object obj = (Object)itrChildElements.next();
        if (obj instanceof Element) {
          uddiReq = (Element)obj;
          break;
        }
      }
      if (uddiReq == null)
        throw new FatalErrorException("A UDDI request was not " +
          "found in the SOAP message.");
     
      // Grab the local name of the UDDI request element
      // from the UDDI Request. If a value isn't returned
      // (either null or an empty String is returned) then
      // throw a FatalError exception. This is probably a
      // configuration problem related to the XML Parser
      // that jUDDI is using.
     
      String operation = uddiReq.getLocalName();
      if ((operation == null) || (operation.trim().length() == 0))
        throw new FatalErrorException("The UDDI service operation " +
          "could not be identified.");
     
      // Grab the generic attribute value (version value).  If
      // one isn't specified or the value specified is not "2.0"
      // then throw an exception (this value must be specified
      // for all UDDI requests and currently only vesion 2.0
      // UDDI requests are supported).

      String version = uddiReq.getAttribute("generic");
      if (version == null)
        throw new FatalErrorException("A UDDI generic attribute " +
          "value was not found for UDDI request: "+operation+" (The " +
          "'generic' attribute must be present)");

      // Verify that the appropriate endpoint was targeted for
      // this service request.  The validateRequest method will
      // throw an UnsupportedException if anything's amiss.

      validateRequest(operation,version,uddiReq);
     
      // Lookup the appropriate XML handler.  Throw an
      // UnsupportedException if one could not be located.

      HandlerMaker maker = HandlerMaker.getInstance();
      IHandler requestHandler = maker.lookup(operation);
      if (requestHandler == null)
        throw new UnsupportedException("The UDDI service operation " +
          "specified is unknown or unsupported: " +operation);
     
      // Unmarshal the raw xml into the appropriate jUDDI
      // request object.

      RegistryObject uddiReqObj = requestHandler.unmarshal(uddiReq);
     
      // 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);
     
      // 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);
    }
    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 errText = null;
     
      // All RegistryException and subclasses of RegistryException
      // should contain values for populating a SOAP Fault as well
      // as a UDDI DispositionReport with specific information
      // about the problem.
      //
      // We've got to dig out the dispositionReport and populate 
      // the SOAP Fault 'detail' element with this information.       
     
      if (ex instanceof RegistryException)
      {
        // Since we've intercepted a RegistryException type
        // then we can assume this is a "controlled" event
        // and simply log the error message without a stack
        // trace.

        log.error(ex.getMessage());

        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
              errText = errInfo.getErrMsg()// UDDI ErrInfo errMsg
            }
          }
        }
      }
      else if (ex instanceof SOAPException)
      {
        log.error(ex.getMessage());
         
        // Because something occured that jUDDI wasn't expecting
        // let's set default SOAP Fault values.  Since SOAPExceptions
        // here are most likely XML validation errors let's blame the
        // client by placing "Client" in the Fault Code and pass
        // the Exception message back to the client.
       
        faultCode = "Client";
        faultString = ex.getMessage();
        faultActor = null;
       
        // Let's set default values for the UDDI DispositionReport
        // here.  While we didn't catch a RegistryException (or
        // subclass) we're going to be friendly and include a
        // FatalError DispositionReport within the message from the
        // SAX parsing problem in the SOAP Fault anyway.
       
        errno = String.valueOf(Result.E_FATAL_ERROR);
        errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
        errText = Result.lookupErrText(Result.E_FATAL_ERROR) +
                  " " + ex.getMessage();
      }
      else // anything else
      {
        // All other exceptions (other than SOAPException or
        // RegistryException and subclasses) are either a result
        // of a jUDDI configuration problem or something that
        // we *should* be catching and converting to a
        // RegistryException but are not (yet!).
           
        log.error(ex.getMessage(),ex);

        // Because something occured that jUDDI wasn't expecting
        // let's set default SOAP Fault values.  Since jUDDI
        // should be catching anything significant let's blame
        // jUDDI by placing "Server" in the Fault Code and pass
        // the Exception message on to the client.
       
        faultCode = "Server";
        faultString = ex.getMessage();
        faultActor = null;
         
        // Let's set default values for the UDDI DispositionReport
        // here.  While we didn't catch a RegistryException (or
        // subclass) but we're going to be friendly and include a
        // FatalError DispositionReport within the SOAP Fault anyway.
       
        errno = String.valueOf(Result.E_FATAL_ERROR);
        errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
        errText = Result.lookupErrText(Result.E_FATAL_ERROR) +
                  " An internal UDDI server error has " +
                  "occurred. Please report this error " +
                  "to the UDDI server administrator.";
      }
     
      // We should have everything we need to assemble
      // the SOAPFault so lets piece it together and
      // send it on it's way.
     
      try {
        SOAPBody soapResBody = soapRes.getSOAPBody();    
        SOAPFault soapFault = soapResBody.addFault();
        soapFault.setFaultCode(faultCode);
        soapFault.setFaultString(faultString);
        soapFault.setFaultActor(faultActor);
       
        // We're always going to include a DispositionReport (for
View Full Code Here

      try
      {
         SOAPMessageContext msgContext = (SOAPMessageContext)context;
         SOAPMessage soapMsg = msgContext.getMessage();
         SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
         SOAPBody body = soapEnv.getBody();
         boolean found = scanNodes(body.getChildNodes());

         if(found) throw new IllegalStateException("XOP request not properly inlined");
                 
      }
      catch (SOAPException ex)
View Full Code Here

      try
      {
         SOAPMessageContext msgContext = (SOAPMessageContext)context;
         SOAPMessage soapMsg = msgContext.getMessage();
         SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
         SOAPBody body = soapEnv.getBody();
         boolean found = scanNodes(body.getChildNodes());

         if(found) throw new IllegalStateException("XOP request not properly inlined");
                 
      }
      catch (SOAPException ex)
View Full Code Here

        {
            Thread.currentThread().setContextClassLoader(deploymentClassLoader) ;
        }
        try
        {
            final SOAPBody soapBody = request.getSOAPBody() ;
            if (soapBody == null)
            {
                throw new WebServiceException("Missing SOAP body from request") ;
            }
            // There is a bug in JBossWS extractContentAsDocument so we do this ourselves
            final Iterator children = soapBody.getChildElements() ;
            boolean found = false ;
            while(children.hasNext())
            {
                final Node node = (Node)children.next() ;
                if (node instanceof SOAPElement)
View Full Code Here

        SOAPPart soapPart = message.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();

        SOAPHeader header = envelope.getHeader();
        SOAPBody body = envelope.getBody();

        header.detachNode();

        Name bodyName = envelope.createName("getQuote", "n", "urn:xmethods-delayed-quotes");
        SOAPBodyElement gltp = body.addBodyElement(bodyName);

        Name name = envelope.createName("symbol");
        SOAPElement symbol = gltp.addChildElement(name);
        symbol.addTextNode(tickerSymbol);

        URLEndpoint endpoint = new URLEndpoint("http://66.28.98.121:9090/soap");
        SOAPMessage response = con.call(message, endpoint);
        con.close();

        SOAPPart sp = response.getSOAPPart();
        SOAPEnvelope se = sp.getEnvelope();
        SOAPBody sb = se.getBody();
        Iterator it = sb.getChildElements();
        while (it.hasNext()) {
            SOAPBodyElement bodyElement = (SOAPBodyElement) it.next();
            Iterator it2 = bodyElement.getChildElements();
            while (it2.hasNext()) {
                SOAPElement element2 = (SOAPElement) it2.next();
View Full Code Here

        MessageFactory msgFactory =
                MessageFactory.newInstance();
        SOAPMessage msg = msgFactory.createMessage();
        SOAPEnvelope envelope =
                msg.getSOAPPart().getEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPFault fault = body.addFault();

        fault.setFaultCode("Client");
        fault.setFaultString(
                "Message does not have necessary info");
        fault.setFaultActor("http://gizmos.com/order");

        Detail detail = fault.addDetail();

        Name entryName = envelope.createName("order", "PO",
                "http://gizmos.com/orders/");
        DetailEntry entry = detail.addDetailEntry(entryName);
        entry.addTextNode(
                "quantity element does not have a value");

        Name entryName2 = envelope.createName("confirmation",
                "PO", "http://gizmos.com/confirm");
        DetailEntry entry2 = detail.addDetailEntry(entryName2);
        entry2.addTextNode("Incomplete address: no zip code");

        msg.saveChanges();

        // Now retrieve the SOAPFault object and its contents
        //after checking to see that there is one

        if (body.hasFault()) {
            fault = body.getFault();
            String code = fault.getFaultCode();
            String string = fault.getFaultString();
            String actor = fault.getFaultActor();

            System.out.println("SOAP fault contains: ");
View Full Code Here

        // Create an envelope in the message
        SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

        // Get hold of the the body
        SOAPBody body = envelope.getBody();

        javax.xml.soap.SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("find_business", "",
                "urn:uddi-org:api"));

        bodyElement.addAttribute(envelope.createName("generic"), "1.0")
                .addAttribute(envelope.createName("maxRows"), "100")
                .addChildElement("name")
View Full Code Here

        SOAPMessage soapMessage =
                messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();
        SOAPEnvelope requestEnvelope =
                soapPart.getEnvelope();
        SOAPBody body = requestEnvelope.getBody();
        SOAPBodyElement operation = body.addBodyElement
                (requestEnvelope.createName("echo"));

        Vector dataHandlersToAdd = new Vector();
        dataHandlersToAdd.add(new DataHandler(new FileDataSource(new
                File(filename))));
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.