KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > clientapi > InOnlyMEPClient


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Runtime state of the engine
17  */

18 package org.apache.axis2.clientapi;
19
20 import org.apache.axis2.addressing.EndpointReference;
21 import org.apache.axis2.addressing.MessageInformationHeadersCollection;
22 import org.apache.axis2.addressing.miheaders.RelatesTo;
23 import org.apache.axis2.context.ConfigurationContext;
24 import org.apache.axis2.context.MessageContext;
25 import org.apache.axis2.context.ServiceContext;
26 import org.apache.axis2.description.OperationDescription;
27 import org.apache.axis2.description.TransportOutDescription;
28 import org.apache.axis2.engine.AxisConfiguration;
29 import org.apache.axis2.engine.AxisEngine;
30 import org.apache.axis2.engine.AxisFault;
31 import org.apache.wsdl.WSDLConstants;
32
33 import javax.xml.namespace.QName JavaDoc;
34
35 public class InOnlyMEPClient extends MEPClient {
36     protected MessageInformationHeadersCollection messageInformationHeaders;
37     protected TransportOutDescription senderTransport;
38     
39     
40     public InOnlyMEPClient(ServiceContext service) {
41         super(service,WSDLConstants.MEP_URI_IN_ONLY);
42         messageInformationHeaders = new MessageInformationHeadersCollection();
43     }
44
45     public void send(OperationDescription axisop, final MessageContext msgctx) throws AxisFault {
46         verifyInvocation(axisop,msgctx);
47         msgctx.setSoapAction(soapAction);
48         msgctx.setMessageInformationHeaders(messageInformationHeaders);
49         msgctx.setServiceContext(serviceContext);
50         ConfigurationContext syscontext = serviceContext.getEngineContext();
51         
52         if(senderTransport == null ){
53             senderTransport = inferTransport(messageInformationHeaders.getTo());
54         }
55         
56         msgctx.setTransportOut(senderTransport);
57
58         ConfigurationContext sysContext = serviceContext.getEngineContext();
59         AxisConfiguration registry = sysContext.getAxisConfiguration();
60
61         AxisEngine engine = new AxisEngine(sysContext);
62         msgctx.setOperationContext(axisop.findOperationContext(msgctx,serviceContext));
63
64         engine.send(msgctx);
65     }
66
67     /**
68      * @param action
69      */

70     public void setWsaAction(String JavaDoc action) {
71         messageInformationHeaders.setAction(action);
72     }
73
74     /**
75      * @param faultTo
76      */

77     public void setFaultTo(EndpointReference faultTo) {
78         messageInformationHeaders.setFaultTo(faultTo);
79     }
80
81     /**
82      * @param from
83      */

84     public void setFrom(EndpointReference from) {
85         messageInformationHeaders.setFrom(from);
86     }
87
88     /**
89      * @param messageId
90      */

91     public void setMessageId(String JavaDoc messageId) {
92         messageInformationHeaders.setMessageId(messageId);
93     }
94
95     /**
96      * @param relatesTo
97      */

98     public void setRelatesTo(RelatesTo relatesTo) {
99         messageInformationHeaders.setRelatesTo(relatesTo);
100     }
101
102     /**
103      * @param replyTo
104      */

105     public void setReplyTo(EndpointReference replyTo) {
106         messageInformationHeaders.setReplyTo(replyTo);
107     }
108
109     /**
110      * @param to
111      */

112     public void setTo(EndpointReference to) {
113         messageInformationHeaders.setTo(to);
114     }
115     
116     public void engageModule(QName JavaDoc name) throws AxisFault{
117         serviceContext.getEngineContext().getAxisConfiguration().engageModule(name);
118     }
119     
120     public void setSenderTransport(String JavaDoc senderTransport) throws AxisFault{
121         this.senderTransport = serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(new QName JavaDoc(senderTransport));
122     }
123  }
124
Popular Tags