KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > saaj > SOAPConnectionImpl


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 package org.apache.axis2.saaj;
17
18 import org.apache.axis2.Constants;
19 import org.apache.axis2.addressing.AddressingConstants;
20 import org.apache.axis2.addressing.EndpointReference;
21 import org.apache.axis2.clientapi.Call;
22 import org.apache.axis2.engine.AxisFault;
23
24 import javax.xml.soap.SOAPConnection JavaDoc;
25 import javax.xml.soap.SOAPException JavaDoc;
26 import javax.xml.soap.SOAPMessage JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.net.URL JavaDoc;
29
30
31 /**
32  * Class SOAPConnectionImpl
33  *
34  * @author Ashutosh Shahi (ashutosh.shahi@gmail.com)
35  *
36  */

37 public class SOAPConnectionImpl extends SOAPConnection JavaDoc {
38     
39     /* (non-Javadoc)
40      * @see javax.xml.soap.SOAPConnection#call(javax.xml.soap.SOAPMessage, java.lang.Object)
41      */

42     public SOAPMessage JavaDoc call(SOAPMessage JavaDoc request, Object JavaDoc endpoint)
43             throws SOAPException JavaDoc {
44         try{
45             org.apache.axis2.soap.SOAPEnvelope envelope = ((SOAPEnvelopeImpl)request.getSOAPPart().getEnvelope()).getOMEnvelope();
46             
47             Call call = new Call();
48             URL JavaDoc url = new URL JavaDoc(endpoint.toString());
49             call.setTransportInfo(Constants.TRANSPORT_HTTP,Constants.TRANSPORT_HTTP, true);
50             call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
51             org.apache.axis2.soap.SOAPEnvelope responseEnv = (org.apache.axis2.soap.SOAPEnvelope)call.invokeBlocking("echo", envelope);
52             SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
53             return new SOAPMessageImpl(response);
54             
55             }catch (MalformedURLException JavaDoc mue) {
56                 throw new SOAPException JavaDoc(mue);
57             }catch (AxisFault af){
58                 throw new SOAPException JavaDoc(af);
59             }
60     }
61
62     
63     /* (non-Javadoc)
64      * @see javax.xml.soap.SOAPConnection#close()
65      */

66     public void close() throws SOAPException JavaDoc {
67         // TODO Auto-generated method stub
68

69     }
70
71 }
72
Popular Tags