KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > io > HttpSoapTag


1 /*
2  * Copyright 1999,2004 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
17 package org.apache.taglibs.io;
18
19 import java.io.BufferedReader JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.io.InputStream JavaDoc;
22 import java.io.InputStreamReader JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.io.OutputStreamWriter JavaDoc;
25 import java.net.HttpURLConnection JavaDoc;
26 import java.net.MalformedURLException JavaDoc;
27 import java.net.URL JavaDoc;
28 import java.net.URLConnection JavaDoc;
29
30 import javax.servlet.ServletContext JavaDoc;
31 import javax.servlet.jsp.JspException JavaDoc;
32 import javax.servlet.jsp.JspWriter JavaDoc;
33 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
34 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
35
36 /** A helper JSP Custom tag which makes a SOAP HTTP POST request.
37   *
38   * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan</a>
39   * @version $Revision: 1.2 $
40   */

41 public class HttpSoapTag extends HttpTag {
42
43     /** The SOAPAction used */
44     private String JavaDoc soapAction;
45     
46     /** The content type used */
47     private String JavaDoc contentType = "text/xml";
48     
49     
50     public HttpSoapTag() {
51         setAction( "POST" );
52     }
53
54     // Properties
55
//-------------------------------------------------------------------------
56
public void setSOAPAction(String JavaDoc soapAction) {
57         this.soapAction = soapAction;
58     }
59
60     // Implementation methods
61
//-------------------------------------------------------------------------
62
protected void configureConnection( URLConnection JavaDoc connection ) throws IOException JavaDoc {
63         super.configureConnection( connection );
64         connection.setRequestProperty( "Content-Type", "text/xml" );
65         connection.setRequestProperty( "SOAPAction", soapAction );
66     }
67 }
68
Popular Tags