You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/09/12 18:55:54 UTC
cvs commit: jakarta-commons/jelly/jelly-tags/soap project.xml
dion 2004/09/12 09:55:54
Modified: jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap
InvokeTag.java SoapTagLibrary.java
jelly/jelly-tags/soap/xdocs changes.xml
jelly/jelly-tags/soap project.xml
Added: jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap
InvokeRawTag.java StringInputStream.java
Log:
Open up new release
Apply Jelly-60 invokeraw tag and username password support
Revision Changes Path
1.6 +30 -11 jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/InvokeTag.java
Index: InvokeTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/InvokeTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- InvokeTag.java 9 Sep 2004 12:16:05 -0000 1.5
+++ InvokeTag.java 12 Sep 2004 16:55:54 -0000 1.6
@@ -41,6 +41,8 @@
private String endpoint = null;
private String namespace = null;
private String method = null;
+ private String username;
+ private String password;
private Service service;
private Object params;
@@ -63,8 +65,7 @@
Object[] params = getParamArray();
if (params == null) {
params = new Object[]{ getBodyText() };
- }
- else {
+ } else {
// invoke body just in case we have nested tags
invokeBody(output);
}
@@ -83,22 +84,23 @@
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName(namespace, method));
+ if ( username != null && !username.equals("") ) {
+ call.setUsername( username );
+ call.setPassword( password );
+ }
+
answer = call.invoke(params);
- }
- catch (MalformedURLException e) {
+ } catch (MalformedURLException e) {
throw new JellyTagException(e);
- }
- catch (ServiceException e) {
+ } catch (ServiceException e) {
throw new JellyTagException(e);
- }
- catch (RemoteException e) {
+ } catch (RemoteException e) {
throw new JellyTagException(e);
}
if (var != null) {
context.setVariable(var, answer);
- }
- else {
+ } else {
// should turn the answer into XML events...
throw new JellyTagException( "Not implemented yet; should stream results as XML events. Results: " + answer );
}
@@ -155,6 +157,23 @@
public void setParams(Object params) {
this.params = params;
}
+
+ /**
+ * Set the password for the SOAP call.
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * Set the username for the SOAP call.
+ */
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
// Implementation methods
//-------------------------------------------------------------------------
1.5 +3 -3 jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/SoapTagLibrary.java
Index: SoapTagLibrary.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/SoapTagLibrary.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SoapTagLibrary.java 9 Sep 2004 12:16:05 -0000 1.4
+++ SoapTagLibrary.java 12 Sep 2004 16:55:54 -0000 1.5
@@ -22,9 +22,9 @@
* @author <a href="mailto:jim@bnainc.net">jim birchfield</a>
* @version $Revision$
*/
-public class SoapTagLibrary extends TagLibrary
-{
+public class SoapTagLibrary extends TagLibrary {
public SoapTagLibrary() {
registerTag("invoke", InvokeTag.class);
+ registerTag("invokeraw", InvokeRawTag.class);
}
}
1.1 jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/InvokeRawTag.java
Index: InvokeRawTag.java
===================================================================
/*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jelly.tags.soap;
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
/**
* Invokes a web service
*
* @author <a href="mailto:jim@bnainc.net">James Birchfield</a>
* @version $Revision: 1.1 $
*/
public class InvokeRawTag extends TagSupport
{
private String var;
private String endpoint = null;
private String soapAction;
public InvokeRawTag()
{
}
// Tag interface
//-------------------------------------------------------------------------
public void doTag(XMLOutput output)
throws MissingAttributeException, JellyTagException
{
if (endpoint == null)
{
throw new MissingAttributeException("endpoint");
}
String request = getBodyText();
String answer = null;
try
{
// Prepare HTTP post
PostMethod post = new PostMethod(endpoint);
// Request content will be retrieved directly
// from the input stream
post.setRequestBody(new StringInputStream(request));
// Per default, the request content needs to be buffered
// in order to determine its length.
// Request body buffering can be avoided when
// = content length is explicitly specified
// = chunk-encoding is used
if (request.length() < Integer.MAX_VALUE)
{
post.setRequestContentLength((int) request.length());
}
else
{
post.setRequestContentLength(
EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
}
// Specify content type and encoding
// If content encoding is not explicitly specified
// ISO-8859-1 is assumed
post.setRequestHeader(
"Content-type",
"text/xml; charset=ISO-8859-1");
// Set the SOAPAction header
if ( soapAction == null )
{
post.setRequestHeader( "SOAPAction", "");
}
else
{
post.setRequestHeader( "SOAPAction", soapAction);
}
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
int result = httpclient.executeMethod(post);
answer = post.getResponseBodyAsString();
// Release current connection to the connection pool once you are done
post.releaseConnection();
}
catch (MalformedURLException e)
{
throw new JellyTagException(e);
}
catch (RemoteException e)
{
throw new JellyTagException(e);
}
catch (HttpException e)
{
throw new JellyTagException(e);
}
catch (IOException e)
{
throw new JellyTagException(e);
}
if (var != null)
{
context.setVariable(var, answer);
}
else
{
// should turn the answer into XML events...
throw new JellyTagException(
"Not implemented yet; should stream results as XML events. Results: "
+ answer);
}
}
// Properties
//-------------------------------------------------------------------------
/**
* Sets the end point to which the invocation will occur
*/
public void setEndpoint(String endpoint)
{
this.endpoint = endpoint;
}
/**
* Sets the name of the variable to output the results of the SOAP call to.
*/
public void setVar(String var)
{
this.var = var;
}
/**
* The SOAPAction HTTP header.
*/
public void setSoapAction(String action)
{
soapAction = action;
}
}
1.1 jakarta-commons/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/StringInputStream.java
Index: StringInputStream.java
===================================================================
/*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jelly.tags.soap;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
/**
* Wraps a String as an InputStream. Note that data will be lost for
* characters not in ISO Latin 1, as a simple char->byte mapping is assumed.
*
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*/
public class StringInputStream
extends InputStream
{
/** Source string, stored as a StringReader */
private StringReader in;
/**
* Composes a stream from a String
*
* @param source The string to read from. Must not be <code>null</code>.
*/
public StringInputStream( String source )
{
in = new StringReader( source );
}
/**
* Reads from the Stringreader, returning the same value. Note that
* data will be lost for characters not in ISO Latin 1. Clients
* assuming a return value in the range -1 to 255 may even fail on
* such input.
*
* @return the value of the next character in the StringReader
*
* @exception IOException if the original StringReader fails to be read
*/
public int read() throws IOException
{
return in.read();
}
/**
* Closes the Stringreader.
*
* @exception IOException if the original StringReader fails to be closed
*/
public void close() throws IOException
{
in.close();
}
/**
* Marks the read limit of the StringReader.
*
* @param limit the maximum limit of bytes that can be read before the
* mark position becomes invalid
*/
public synchronized void mark( final int limit )
{
try
{
in.mark( limit );
}
catch ( IOException ioe )
{
throw new RuntimeException( ioe.getMessage() );
}
}
/**
* Resets the StringReader.
*
* @exception IOException if the StringReader fails to be reset
*/
public synchronized void reset() throws IOException
{
in.reset();
}
/**
* @see InputStream#markSupported
*/
public boolean markSupported()
{
return in.markSupported();
}
}
1.3 +3 -0 jakarta-commons/jelly/jelly-tags/soap/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/soap/xdocs/changes.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- changes.xml 12 Sep 2004 14:44:37 -0000 1.2
+++ changes.xml 12 Sep 2004 16:55:54 -0000 1.3
@@ -24,6 +24,9 @@
<author email="dion@apache.org">dIon Gillard</author>
</properties>
<body>
+ <release version="1.1-SNAPSHOT" date="in CVS">
+ <action dev="dion" type="add" issue="JELLY-60" due-to="Dan Diephouse">add invoke raw tag</action>
+ </release>
<release version="1.0" date="2004-09-12">
</release>
</body>
1.13 +7 -1 jakarta-commons/jelly/jelly-tags/soap/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/soap/project.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- project.xml 12 Sep 2004 14:44:37 -0000 1.12
+++ project.xml 12 Sep 2004 16:55:54 -0000 1.13
@@ -18,7 +18,7 @@
<extend>${basedir}/../tag-project.xml</extend>
<id>commons-jelly-tags-soap</id>
<name>commons-jelly-tags-soap</name>
- <currentVersion>1.0</currentVersion>
+ <currentVersion>1.1-SNAPSHOT</currentVersion>
<package>org.apache.commons.jelly.tags.soap</package>
<description>
@@ -47,6 +47,12 @@
<dependency>
<id>axis</id>
<version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>2.0</version>
</dependency>
<!-- can be found in jwsdp-1.3/jaxrpc/lib -->
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org