Package org.jboss.ws.core.soap

Examples of org.jboss.ws.core.soap.SOAPContentElement


         xmlName = namespaceRegistry.registerQName(xmlName);
      }

      Name soapName = new NameImpl(xmlName.getLocalPart(), xmlName.getPrefix(), xmlName.getNamespaceURI());

      SOAPContentElement contentElement;
      if (soapElement instanceof SOAPHeader)
      {
         contentElement = new SOAPHeaderElementImpl(soapName);
         soapElement.addChildElement(contentElement);
      }
      else
      {
         Style style = paramMetaData.getOperationMetaData().getStyle();
         if (style == Style.DOCUMENT)
         {
            contentElement = new SOAPBodyElementDoc(soapName);
            soapElement.addChildElement(contentElement);
         }
         else
         {
            contentElement = new SOAPContentElement(soapName);
            soapElement.addChildElement(contentElement);
         }
      }

      contentElement.setParamMetaData(paramMetaData);

      if (paramMetaData.isSOAPArrayParam())
      {
         log.trace("Add parameter as SOAP encoded Array");
         contentElement.addNamespaceDeclaration(Constants.PREFIX_SOAP11_ENC, Constants.URI_SOAP11_ENC);
      }

      // When a potential xop parameter is detected and MTOM is enabled
      // we flag the SOAP message as a XOP package
      if (paramMetaData.isXOP() && XOPContext.isMTOMEnabled())
      {
         log.trace("Add parameter as XOP");
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
         soapMessage.setXOPMessage(true);
      }
      else if (paramMetaData.isSwaRef())
      {
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
         soapMessage.setSWARefMessage(true);
      }

      contentElement.setObjectValue(value);

      return contentElement;
   }
View Full Code Here


   /** Unmarshall a message element and add it to the parameter list */
   private SOAPContentElement getParameterFromMessage(ParameterMetaData paramMetaData, SOAPElement soapElement, boolean optional) throws BindingException
   {
      Name xmlName = new NameImpl(paramMetaData.getXmlName());

      SOAPContentElement soapContentElement = null;
      Iterator childElements = soapElement.getChildElements();
      while (childElements.hasNext())
      {
         Object childNode = childElements.next();
         if (childNode instanceof SOAPElement)
         {
            SOAPElementImpl childElement = (SOAPElementImpl)childNode;
            // If this message was manipulated by a handler the child may not be a content element
            if (!(childElement instanceof SOAPContentElement))
               childElement = (SOAPContentElement)soapElement.replaceChild(new SOAPContentElement(childElement), childElement);

            // The parameters are expected to be lazy
            SOAPContentElement aux = (SOAPContentElement)childElement;
            Name elName = aux.getElementName();

            if (xmlName.getLocalName().equals("") || xmlName.equals(elName))
            {
               soapContentElement = aux;
               soapContentElement.setParamMetaData(paramMetaData);
               break;
            }

            if (SOAP_ARRAY_NAME.equals(elName))
            {
               CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
               msgContext.put(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
               try
               {
                  QName compXMLName = paramMetaData.getXmlName();
                  Element compElement = DOMUtils.getFirstChildElement(aux);
                  // NPE when the soap encoded array size is 0 on the return path
                  // http://jira.jboss.org/jira/browse/JBWS-1285
                  if (compElement == null || compElement.getNodeName().equals(compXMLName.getLocalPart()))
                  {
                     soapContentElement = aux;
                     soapContentElement.setParamMetaData(paramMetaData);
                     break;
                  }
               }
               finally
               {
                  msgContext.remove(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
               }
            }
         }
      }

      // If matching by name fails, try to match by xmlType
      // This maybe necessary when wsa:Action dispatches to the operation
      if (soapContentElement == null)
      {
         childElements = soapElement.getChildElements();
         OperationMetaData opMetaData = paramMetaData.getOperationMetaData();
         TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
         if (childElements.hasNext() && opMetaData.getStyle() == Style.DOCUMENT)
         {
            SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();

            // The parameters are expected to be lazy
            SOAPContentElement aux = (SOAPContentElement)childElement;
            Name elName = aux.getElementName();
            QName elType = null;

            XSElementDeclaration xsdElement = typesMetaData.getSchemaModel().getElementDeclaration(elName.getLocalName(), elName.getURI());
            if (xsdElement != null && xsdElement.getTypeDefinition() != null)
            {
View Full Code Here

         QName xmlName = paramMetaData.getXmlName();

         SOAPMessage reqMessage = (SOAPMessage)payload;
         SOAPBodyImpl body = (SOAPBodyImpl)reqMessage.getSOAPBody();
        
         SOAPContentElement bodyElement = (SOAPContentElement)body.getBodyElement();
         Source source = bodyElement.getXMLFragment().getSource();
         if (source == null)
            throw new IllegalStateException("Payload cannot be null");

         epInv.setRequestParamValue(xmlName, source);
View Full Code Here

         msgContext.setSOAPMessage(resMessage);

         ParameterMetaData retParameter = opMetaData.getReturnParameter();
         QName xmlName = retParameter.getXmlName();
         SOAPBodyImpl soapBody = (SOAPBodyImpl)resMessage.getSOAPBody();
         SOAPContentElement bodyElement = new SOAPBodyElementDoc(xmlName);
         bodyElement = (SOAPContentElement)soapBody.addChildElement(bodyElement);

         Source payload = (Source)epInv.getReturnValue();
         bodyElement.setXMLFragment(new XMLFragment(payload));

         return resMessage;
      }
      catch (Exception e)
      {
View Full Code Here

         {
            source = new DOMSource(bodyElement);
         }
         else
         {
            SOAPContentElement contentElement = (SOAPContentElement)bodyElement;
            source = contentElement.getXMLFragment().getSource();
         }
      }
      else if (message instanceof HTTPMessageImpl)
      {
         HTTPMessageImpl httpMessage = (HTTPMessageImpl)message;
View Full Code Here

                  WSException.rethrow(ex);
               }
            }
            else
            {
               SOAPContentElement contentElement = (SOAPContentElement)bodyElement;
               contentElement.setXMLFragment(new XMLFragment(source));
            }
         }
         catch (SOAPException ex)
         {
            throw new WebServiceException("Cannot set xml payload", ex);
View Full Code Here

      if (message instanceof SOAPMessage)
      {
         SOAPMessage soapMessage = (SOAPMessage)message;
         SOAPBodyImpl soapBody = getSOAPBody(soapMessage);

         SOAPContentElement bodyElement = (SOAPContentElement)soapBody.getFirstChild();
         if (bodyElement != null)
         {
            payload = bodyElement.getObjectValue();
         }
      }
      else if (message instanceof HTTPMessageImpl)
      {
         throw new NotImplementedException();
View Full Code Here

      if (message instanceof SOAPMessage)
      {
         SOAPMessage soapMessage = (SOAPMessage)message;
         SOAPBodyImpl soapBody = getSOAPBody(soapMessage);

         SOAPContentElement bodyElement = (SOAPContentElement)soapBody.getFirstChild();
         if (bodyElement != null)
         {
            bodyElement.setObjectValue(payload);
            MessageContextAssociation.peekMessageContext().setModified(true);
         }
      }
      else if (message instanceof HTTPMessageImpl)
      {
View Full Code Here

            Source source = (Source)obj;
            if (mode == Mode.PAYLOAD)
            {
               reqMsg = (SOAPMessageImpl)factory.createMessage();
               SOAPBodyImpl soapBody = (SOAPBodyImpl)reqMsg.getSOAPBody();
               SOAPContentElement bodyElement = new SOAPBodyElementDoc(SOAPBodyElementDoc.GENERIC_PARAM_NAME);
               bodyElement = (SOAPContentElement)soapBody.addChildElement(bodyElement);
               XMLFragment xmlFragment = new XMLFragment(source);
               bodyElement.setXMLFragment(xmlFragment);

               // validate payload if necessary
               if (validateDispatch)
               {
                  // expand to DOM will validate the contents
                  xmlFragment.toElement();
               }

            }
            if (mode == Mode.MESSAGE)
            {
               TransformerFactory tf = TransformerFactory.newInstance();
               ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
               tf.newTransformer().transform(source, new StreamResult(baos));
               reqMsg = (SOAPMessageImpl)factory.createMessage(null, new ByteArrayInputStream(baos.toByteArray()));
            }
         }
         else if (jaxbContext != null)
         {
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
            marshaller.marshal(obj, baos);

            reqMsg = (SOAPMessageImpl)factory.createMessage();
            SOAPBodyImpl soapBody = (SOAPBodyImpl)reqMsg.getSOAPBody();
            SOAPContentElement bodyElement = new SOAPBodyElementDoc(SOAPBodyElementDoc.GENERIC_PARAM_NAME);
            bodyElement = (SOAPContentElement)soapBody.addChildElement(bodyElement);
            StreamSource source = new StreamSource(new ByteArrayInputStream(baos.toByteArray()));
            bodyElement.setXMLFragment(new XMLFragment(source));
         }
      }
      catch (RuntimeException rte)
      {
         throw rte;
View Full Code Here

       "<Customer>" +
        "<Name>Thomas</Name>" +
       "</Customer>" +
      "</tns:Order>";

      SOAPContentElement soapEl = new SOAPContentElement(name);
      soapEl.setXMLFragment(new XMLFragment(xmlFragment) );

      assertEquals(name, soapEl.getElementName());

      Iterator it = soapEl.getChildElements();
      SOAPElement child1 = (SOAPElement)it.next();
      assertEquals("OrderItem", child1.getNodeName());
      assertEquals("Ferarri", child1.getValue());

      SOAPElement child2 = (SOAPElement)it.next();
View Full Code Here

TOP

Related Classes of org.jboss.ws.core.soap.SOAPContentElement

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.