summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/samples/helloworld/helloworldaxis2/src/main/java/org/apache/tuscany/samples/helloworldaxis/HelloWorldServiceImplMessageReceiver.java
blob: 90e9af80b2377751e3b0c6770d952a9d0378535c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
 * HelloWorldServiceImplMessageReceiver.java This file was auto-generated from
 * WSDL by the Apache Axis2 version: 0.94-SNAPSHOT Jan 10, 2006 (10:21:58 LKT)
 */
package org.apache.tuscany.samples.helloworldaxis;

/**
 * HelloWorldServiceImplMessageReceiver message receiver
 */
public class HelloWorldServiceImplMessageReceiver
    extends org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver {
    public void invokeBusinessLogic(
        org.apache.axis2.context.MessageContext msgContext,
        org.apache.axis2.context.MessageContext newMsgContext)
        throws org.apache.axis2.AxisFault {
        try {
            // get the implementation class for the Web Service
            Object obj = getTheImplementationObject(msgContext);

            //Inject the Message Context if it is asked for
            org.apache.axis2.engine.DependencyManager.configureBusinessLogicProvider(obj,
                msgContext, newMsgContext);

            HelloWorldServiceImplSkeleton skel = (HelloWorldServiceImplSkeleton) obj;

            //Out Envelop
            org.apache.axis2.soap.SOAPEnvelope envelope = null;

            //Find the axisOperation that has been set by the Dispatch phase.
            org.apache.axis2.description.AxisOperation op = msgContext.getOperationContext()
                                                                      .getAxisOperation();

            if (op == null) {
                throw new org.apache.axis2.AxisFault(
                    "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
            }

            String methodName;

            if ((op.getName() != null) &
                    ((methodName = op.getName().getLocalPart()) != null)) {
                if ("getGreetings".equals(methodName)) {
                    org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse param5 =
                        null;

                    //doc style
                    param5 = skel.getGreetings((org.apache.tuscany.samples.helloworldaxis.GetGreetings) fromOM(
                                msgContext.getEnvelope().getBody()
                                          .getFirstElement(),
                                org.apache.tuscany.samples.helloworldaxis.GetGreetings.class));

                    envelope = toEnvelope(getSOAPFactory(msgContext), param5);
                }

                newMsgContext.setEnvelope(envelope);
            }
        } catch (Exception e) {
            throw org.apache.axis2.AxisFault.makeFault(e);
        }
    }

    //
    private org.apache.axis2.om.OMElement toOM(
        org.apache.tuscany.samples.helloworldaxis.GetGreetings param) {
        if (param instanceof org.apache.axis2.databinding.ADBBean) {
            org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder(org.apache.axis2.om.OMAbstractFactory.getOMFactory(),
                    param.getPullParser(
                        org.apache.tuscany.samples.helloworldaxis.GetGreetings.MY_QNAME));
            org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
            ((org.apache.axis2.om.impl.OMNodeEx) documentElement).setParent(null); // remove the parent link

            return documentElement;
        } else {
            //todo finish this onece the bean serializer has the necessary methods
            return null;
        }
    }

    private org.apache.axis2.soap.SOAPEnvelope toEnvelope(
        org.apache.axis2.soap.SOAPFactory factory,
        org.apache.tuscany.samples.helloworldaxis.GetGreetings param) {
        if (param instanceof org.apache.axis2.databinding.ADBBean) {
            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(
                        org.apache.tuscany.samples.helloworldaxis.GetGreetings.MY_QNAME),
                    factory);

            return builder.getEnvelope();
        } else {
            //todo finish this onece the bean serializer has the necessary methods
            return null;
        }
    }

    private org.apache.axis2.om.OMElement toOM(
        org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse param) {
        if (param instanceof org.apache.axis2.databinding.ADBBean) {
            org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder(org.apache.axis2.om.OMAbstractFactory.getOMFactory(),
                    param.getPullParser(
                        org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse.MY_QNAME));
            org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
            ((org.apache.axis2.om.impl.OMNodeEx) documentElement).setParent(null); // remove the parent link

            return documentElement;
        } else {
            //todo finish this onece the bean serializer has the necessary methods
            return null;
        }
    }

    private org.apache.axis2.soap.SOAPEnvelope toEnvelope(
        org.apache.axis2.soap.SOAPFactory factory,
        org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse param) {
        if (param instanceof org.apache.axis2.databinding.ADBBean) {
            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(
                        org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse.MY_QNAME),
                    factory);

            return builder.getEnvelope();
        } else {
            //todo finish this onece the bean serializer has the necessary methods
            return null;
        }
    }

    private java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
        java.lang.Class type) {
        Object obj;

        try {
            java.lang.reflect.Method parseMethod = type.getMethod("parse",
                    new Class[] { javax.xml.stream.XMLStreamReader.class });
            obj = null;

            if (parseMethod != null) {
                obj = parseMethod.invoke(null,
                        new Object[] { param.getXMLStreamReaderWithoutCaching() });
            } else {
                //oops! we don't know how to deal with this. Perhaps the reflective one is a good choice here
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return obj;
    }
}