Try this.

You will need to compile it, instruction on how to do that are in the
java CFX section of the cf documentation;

Save it as sendXMLData.java

And compile;

Javac -classpath cfx.jar sendXMLData.java

This should produce a class file, stick that in x:\cfusion\java\classes
and register it as a custom tag.

Then just call it like;

<cfx_sendXMLData url="http://yoururlhere.com"; XMLData="">
<cfoutput>#Response#</cfoutput>


This probably isn't great java, but it is however very fast and stable, 

Good luck, Craig.

---

import com.allaire.cfx.* ;
import java.io.* ;
import java.net.* ;
import java.util.* ;

public class sendXMLData implements CustomTag{
   public void processRequest( Request request, Response response )
throws Exception
   {
                if ( !request.attributeExists("XMLData") ||
!request.attributeExists("Url") )                       
                {
                   throw new Exception( 
                      "Missing attribute (XMLData and Url are required
attributes for this tag)" ) ;
                }
                
                String Url = request.getAttribute("Url") ; 
                String messageBody = request.getAttribute("XMLData");

                        
                URL url = new URL( Url );
                
                HttpURLConnection connection = ( HttpURLConnection )
url.openConnection();
        
                connection.setDoOutput( true );
                connection.setDoInput( true );
                connection.setRequestMethod( "POST" );
                connection.setUseCaches( false );
                connection.setRequestProperty( "Content-type",
"application/x-www-form-urlencoded");
        
                String dataString = "XMLData=" +
URLEncoder.encode(XMLData);
        
                DataOutputStream dos = new DataOutputStream(
connection.getOutputStream() );
        
                dos.writeBytes( dataString );
                dos.flush();
                dos.close();
        
                InputStream is = connection.getInputStream();
                BufferedReader reader = new BufferedReader( new
InputStreamReader( is ));
                StringBuffer answer = new StringBuffer();
                String line = null;
        
                while ( ( line = reader.readLine() ) != null ){
                answer.append(line);
                }
        
                is.close();

                response.setVariable( "Response", answer.toString());
        }
}



---

-----Original Message-----
From: Frank Mamone [mailto:[EMAIL PROTECTED]] 
Sent: 29 November 2002 16:03
To: CF-Talk
Subject: Re: Posting XML

Looks like their download site is down. Do you have their tag and can
you
send it to me ?

Thanks
----- Original Message -----
From: "webguy" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, November 29, 2002 10:19 AM
Subject: RE: Posting XML


> have a look here ...
>
>
http://www.granularity.net/technologies/xml/Granularity-Sending_and_Reci
vein
> g_XML_with_ColdFusion.pdf
>
> WG
>
> > -----Original Message-----
> > From: Frank Mamone [mailto:[EMAIL PROTECTED]]
> > Sent: 29 November 2002 15:13
> > To: CF-Talk
> > Subject: Re: Posting XML
> >
> >
> > Is there a known Java component or tag I can use with CF 4.5 to
> > make to type
> > of post reliably?
> >
> > I'll look around the dev exchange.
> >
> >
> > ----- Original Message -----
> > From: "Craig Dudley" <[EMAIL PROTECTED]>
> > To: "CF-Talk" <[EMAIL PROTECTED]>
> > Sent: Friday, November 29, 2002 5:22 AM
> > Subject: RE: Posting XML
> >
> >
> > > It's not quite the same thing as a simple html form, a form can't
be
> > > posted automatically by the server and the response processed in
the
> > > same thread for example.
> > >
> > > Cfhttp is fine for occasional posts, but beware. It's slow, flaky
and
> > > basically crap under heavy load. Java is the way to go.
> > >
> > > -----Original Message-----
> > > From: Frank Mamone [mailto:[EMAIL PROTECTED]]
> > > Sent: 29 November 2002 04:33
> > > To: CF-Talk
> > > Subject: Re: Posting XML
> > >
> > > Thanks. Works better than a simple form doing the same thing for
some
> > > reason!
> > >
> > >
> > > ----- Original Message -----
> > > From: "Matthew Walker" <[EMAIL PROTECTED]>
> > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > Sent: Thursday, November 28, 2002 10:37 PM
> > > Subject: RE: Posting XML
> > >
> > >
> > > > Use something like:
> > > >
> > > > <cfhttp url="www.site.com" method="post" resolveurl="no">
> > > > <cfhttpparam type="formfield" name="myXml" value="#myXml#" >
> > > > </cfhttp>
> > > >
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Frank Mamone [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Friday, 29 November 2002 4:33 p.m.
> > > > > To: CF-Talk
> > > > > Subject: Posting XML
> > > > >
> > > > >
> > > > > I am working on an R&D project using WCTP which is an XML
> > > > > specification. Apparently, I need to POST the XML using HTTP
> > > > > 1.0 or 1.1. I really don't know what they mean as the only
> > > > > posting I know how to do is through a HTML form.
> > > > >
> > > > > I've read all the documentation and can't find an example of
> > > > > how it's done. Is there a way using CFMX or otherwise to post
> > > > > an XML document to a URL without using a form?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Frank
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to