summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/samples/helloworld/helloworldaxis2/src/main/java/org/apache/tuscany/samples/helloworldaxis/HelloWorldServiceImplStub.java
blob: 440a5aa36fc8d21cb141cb8fc173340c0ed62d4b (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/**
 * HelloWorldServiceImplStub.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;

/*
 *  HelloWorldServiceImplStub java implementation
 */
public class HelloWorldServiceImplStub
    extends org.apache.axis2.client.Stub
{
    //default axis home being null forces the system to pick up the mars from the axis2 library
    public static final String AXIS2_HOME = null;

    protected static org.apache.axis2.description.AxisOperation[] _operations;

    static
    {
        //creating the Service
        _service = new org.apache.axis2.description.AxisService( "HelloWorldServiceImpl" );

        //creating the operations
        org.apache.axis2.description.AxisOperation __operation;
        _operations = new org.apache.axis2.description.OutInAxisOperation[1];

        __operation = new org.apache.axis2.description.OutInAxisOperation();
        __operation.setName( new javax.xml.namespace.QName( "http://helloworldaxis.samples.tuscany.apache.org",
                                                            "getGreetings" ) );
        _operations[0] = __operation;
        _service.addOperation( __operation );
    }

    public HelloWorldServiceImplStub( org.apache.axis2.context.ConfigurationContext configurationContext,
                                     String targetEndpoint )
        throws java.lang.Exception
    {
        _serviceClient = new org.apache.axis2.client.ServiceClient( configurationContext, _service );
        _serviceClient.getOptions().setTo( new org.apache.axis2.addressing.EndpointReference( targetEndpoint ) );
    }

    /**
     * Default Constructor
     */
    public HelloWorldServiceImplStub()
        throws java.lang.Exception
    {
        this( "http://localhost:8080/axis2/services/HelloWorldServiceImplService" );
    }

    /**
     * Constructor taking the traget endpoint
     */
    public HelloWorldServiceImplStub( String targetEndpoint )
        throws java.lang.Exception
    {
        this( new org.apache.axis2.context.ConfigurationContextFactory()
            .createConfigurationContextFromFileSystem( AXIS2_HOME ), targetEndpoint );
    }

    /**
     * Auto generated method signature
     *
     * @param param10
     *
     * @see org.apache.tuscany.samples.helloworldaxis.HelloWorldServiceImpl#getGreetings
     */
    public org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse getGreetings(
                                                                                       org.apache.tuscany.samples.helloworldaxis.GetGreetings param10 )
        throws java.rmi.RemoteException
    {
        org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient( _operations[0]
            .getName() );
        _operationClient.getOptions().setSoapAction( "" );
        _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault( true );

        // create SOAP envelope with that payload
        org.apache.axis2.soap.SOAPEnvelope env = null;

        //Style is Doc.
        env = toEnvelope( getFactory( _options.getSoapVersionURI() ), param10 );

        // create message context with that soap envelope
        org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
        _messageContext.setEnvelope( env );

        // add the message contxt to the operation client
        _operationClient.addMessageContext( _messageContext );

        //set the options hierarchy
        _options.setParent( _operationClient.getOptions() );
        _operationClient.setOptions( _options );

        //execute the operation client
        _operationClient.execute( true );

        org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient
            .getMessageContext( org.apache.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE );
        org.apache.axis2.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();

        java.lang.Object object = fromOM( getElement( _returnEnv, "doc" ),
                                          org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse.class );

        return (org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse) object;
    }

    /**
     * Auto generated method signature for Asynchronous Invocations
     *
     * @param param10
     *
     * @see org.apache.tuscany.samples.helloworldaxis.HelloWorldServiceImpl#startgetGreetings
     */
    public void startgetGreetings(
                                  org.apache.tuscany.samples.helloworldaxis.GetGreetings param10,
                                  final org.apache.tuscany.samples.helloworldaxis.HelloWorldServiceImplCallbackHandler callback )
        throws java.rmi.RemoteException
    {
        org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient( _operations[0]
            .getName() );
        _operationClient.getOptions().setSoapAction( "" );
        _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault( true );

        // create SOAP envelope with that payload
        org.apache.axis2.soap.SOAPEnvelope env;

        //Style is Doc.
        env = toEnvelope( getFactory( _options.getSoapVersionURI() ), param10 );

        // create message context with that soap envelope
        org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
        _messageContext.setEnvelope( env );

        // add the message contxt to the operation client
        _operationClient.addMessageContext( _messageContext );

        //set the options hierarchy
        _options.setParent( _operationClient.getOptions() );
        _operationClient.setOptions( _options );

        _operationClient.setCallback( new org.apache.axis2.client.async.Callback()
        {
            public void onComplete( org.apache.axis2.client.async.AsyncResult result )
            {
                java.lang.Object object = fromOM( getElement( result.getResponseEnvelope(), "doc" ),
                                                  org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse.class );
                callback
                    .receiveResultgetGreetings( (org.apache.tuscany.samples.helloworldaxis.GetGreetingsResponse) object );
            }

            public void onError( java.lang.Exception e )
            {
                callback.receiveErrorgetGreetings( e );
            }
        } );

        //execute the operation client
        _operationClient.execute( true );
    }

    //http://localhost:8080/axis2/services/HelloWorldServiceImplService
    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;
    }
}