Search in sources :

Example 6 with AxisMessage

use of org.apache.axis2.transport.testkit.message.AxisMessage in project wso2-axis2-transports by wso2.

the class XMPPSender method getParameterListForOperation.

/**
 * Retrieves list of parameter names & their type for a given operation
 * @param operation
 */
private static String getParameterListForOperation(AxisOperation operation) {
    // Logic copied from BuilderUtil.buildsoapMessage(...)
    StringBuffer paramList = new StringBuffer();
    AxisMessage axisMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement();
    if (xmlSchemaElement != null) {
        XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
        if (schemaType instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
            XmlSchemaParticle particle = complexType.getParticle();
            if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
                XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) particle;
                Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
                while (iterator.hasNext()) {
                    XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
                    QName qName = innerElement.getQName();
                    if (qName == null && innerElement.getSchemaTypeName().equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
                        break;
                    }
                    long minOccurs = innerElement.getMinOccurs();
                    boolean nillable = innerElement.isNillable();
                    String name = qName != null ? qName.getLocalPart() : innerElement.getName();
                    String type = innerElement.getSchemaTypeName().toString();
                    paramList.append("," + type + " " + name);
                }
            }
        }
    }
    // remove first ","
    String list = paramList.toString();
    return list.replaceFirst(",", "");
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) Iterator(java.util.Iterator) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) AxisMessage(org.apache.axis2.description.AxisMessage)

Example 7 with AxisMessage

use of org.apache.axis2.transport.testkit.message.AxisMessage in project wso2-axis2-transports by wso2.

the class AxisAsyncEndpoint method receive.

void receive(MessageContext messageCtx) throws AxisFault {
    log.debug("MessageReceiver has been invoked");
    final AxisMessage messageData;
    try {
        Assert.assertTrue(messageCtx.isServerSide());
        TransportInDescription transportIn = messageCtx.getTransportIn();
        Assert.assertNotNull("transportIn not set on message context", transportIn);
        Assert.assertEquals(context.getTransportName(), transportIn.getName());
        Assert.assertEquals(context.getTransportName(), messageCtx.getIncomingTransportName());
        for (MessageContextValidator validator : validators) {
            validator.validate(messageCtx, false);
        }
        messageData = new AxisMessage(messageCtx);
    } catch (Throwable ex) {
        support.putException(ex);
        return;
    }
    support.putMessage(null, messageData);
}
Also used : TransportInDescription(org.apache.axis2.description.TransportInDescription) AxisMessage(org.apache.axis2.transport.testkit.message.AxisMessage) MessageContextValidator(org.apache.axis2.transport.testkit.axis2.MessageContextValidator)

Aggregations

MessageContext (org.apache.axis2.context.MessageContext)4 AxisMessage (org.apache.axis2.transport.testkit.message.AxisMessage)3 QName (javax.xml.namespace.QName)2 AxisMessage (org.apache.axis2.description.AxisMessage)2 AxisOperation (org.apache.axis2.description.AxisOperation)2 MessageContextValidator (org.apache.axis2.transport.testkit.axis2.MessageContextValidator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Iterator (java.util.Iterator)1 ContentType (javax.mail.internet.ContentType)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Attachments (org.apache.axiom.attachments.Attachments)1 OMElement (org.apache.axiom.om.OMElement)1 OMNamespace (org.apache.axiom.om.OMNamespace)1 OMNode (org.apache.axiom.om.OMNode)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1