Quantcast

Posting a XML parameter through HTTP Post request

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Posting a XML parameter through HTTP Post request

shaun lim jin
Hello all,

I'm trying to pass a StringWriter instance containing a block of XML through a HTTP post request as a parameter.

I have been googling for the entire morning/afternoon and still can't get it to work. Any ideas, people?

Sorry, I'm very very new to grails/groovy.

Cheers
Shaun
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
See http://groovy.codehaus.org/modules/http-builder/doc/xml.html

On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:

>
> Hello all,
>
> I'm trying to pass a StringWriter instance containing a block of XML through
> a HTTP post request as a parameter.
>
> I have been googling for the entire morning/afternoon and still can't get it
> to work. Any ideas, people?
>
> Sorry, I'm very very new to grails/groovy.
>
> Cheers
> Shaun
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Should have mentioned -- while the example shows an using an XML
builder, you should be able to pass your string writer as-is like so:

def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )

def resp = http.request( POST, XML ) {
  body = someStringWriterThatWillOutputXML
}

println resp.statusCode


On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]> wrote:

> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>
> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>
>> Hello all,
>>
>> I'm trying to pass a StringWriter instance containing a block of XML through
>> a HTTP post request as a parameter.
>>
>> I have been googling for the entire morning/afternoon and still can't get it
>> to work. Any ideas, people?
>>
>> Sorry, I'm very very new to grails/groovy.
>>
>> Cheers
>> Shaun
>> --
>> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>> Sent from the groovy - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

shaun lim jin
Thanks Tom for the help. I am getting this error msg though:

-

Error 500: java.lang.NoClassDefFoundError: groovyx/net/http/HttpResponseException
Servlet: grails
URI: /ZongTest/grails/oneOff/pricepoints.dispatch
Exception Message: groovyx.net.http.HttpResponseException
Caused by: java.lang.NoClassDefFoundError: groovyx/net/http/HttpResponseException
Class: Unknown

-

My code is as follows:

-
    def pricepoints = {

        def priceLookUp = new PriceLookUp(customerKey: params.customerKey, countryCode: params.countryCode, currency: params.currency)

        def request = '<?xml version="1.0" encoding="UTF-8"?>'
        request = request + "\n" + (priceLookUp.generateXML())

        def urlString = "http://apps.zong.com/zong-cash/actions/default?method=lookup"

        def http = new HTTPBuilder(urlString)

        http.request(POST, XML){
            //delegate.contentType = "text/plain"
            //delegate.headers['Content-Type'] = "text/xml"
            delegate.body = request  
        }
        println resp.statusCode


    }
-
Tom Nichols wrote
Should have mentioned -- while the example shows an using an XML
builder, you should be able to pass your string writer as-is like so:

def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )

def resp = http.request( POST, XML ) {
  body = someStringWriterThatWillOutputXML
}

println resp.statusCode


On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<tmnichols@gmail.com> wrote:
> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>
> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<shaun@zong.com> wrote:
>>
>> Hello all,
>>
>> I'm trying to pass a StringWriter instance containing a block of XML through
>> a HTTP post request as a parameter.
>>
>> I have been googling for the entire morning/afternoon and still can't get it
>> to work. Any ideas, people?
>>
>> Sorry, I'm very very new to grails/groovy.
>>
>> Cheers
>> Shaun
>> --
>> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>> Sent from the groovy - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Well, NoClassDefFoundError usually indicates a classpath problem.  As
a sanity check, open the http-builder JAR and you should see
groovyx/net/http/HttpResponseException.class.  I believe this class
was introduced in 0.5.0 -- is it possible you have a 0.4.x
HTTP-Builder JAR somewhere on your classpath?

-Tom


2009/8/19 ShaunLim <[hidden email]>:

>
> Thanks Tom for the help. I am getting this error msg though:
>
> -
>
> Error 500: java.lang.NoClassDefFoundError:
> groovyx/net/http/HttpResponseException
> Servlet: grails
> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
> Exception Message: groovyx.net.http.HttpResponseException
> Caused by: java.lang.NoClassDefFoundError:
> groovyx/net/http/HttpResponseException
> Class: Unknown
>
> -
>
> My code is as follows:
>
> -
>    def pricepoints = {
>
>        def priceLookUp = new PriceLookUp(customerKey: params.customerKey,
> countryCode: params.countryCode, currency: params.currency)
>
>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>        request = request + "\n" + (priceLookUp.generateXML())
>
>        def urlString =
> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>
>        def http = new HTTPBuilder(urlString)
>
>        http.request(POST, XML){
>            //delegate.contentType = "text/plain"
>            //delegate.headers['Content-Type'] = "text/xml"
>            delegate.body = request
>        }
>        println resp.statusCode
>
>
>    }
> -
>
> Tom Nichols wrote:
>>
>> Should have mentioned -- while the example shows an using an XML
>> builder, you should be able to pass your string writer as-is like so:
>>
>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>
>> def resp = http.request( POST, XML ) {
>>   body = someStringWriterThatWillOutputXML
>> }
>>
>> println resp.statusCode
>>
>>
>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]> wrote:
>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>
>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>>>
>>>> Hello all,
>>>>
>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>> through
>>>> a HTTP post request as a parameter.
>>>>
>>>> I have been googling for the entire morning/afternoon and still can't
>>>> get it
>>>> to work. Any ideas, people?
>>>>
>>>> Sorry, I'm very very new to grails/groovy.
>>>>
>>>> Cheers
>>>> Shaun
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

shaun lim jin
I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1 folder" that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all residing in the "lib" directory of my project directory.

And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm just about tearing my hair out.

Tom Nichols wrote
Well, NoClassDefFoundError usually indicates a classpath problem.  As
a sanity check, open the http-builder JAR and you should see
groovyx/net/http/HttpResponseException.class.  I believe this class
was introduced in 0.5.0 -- is it possible you have a 0.4.x
HTTP-Builder JAR somewhere on your classpath?

-Tom


2009/8/19 ShaunLim <shaun@zong.com>:
>
> Thanks Tom for the help. I am getting this error msg though:
>
> -
>
> Error 500: java.lang.NoClassDefFoundError:
> groovyx/net/http/HttpResponseException
> Servlet: grails
> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
> Exception Message: groovyx.net.http.HttpResponseException
> Caused by: java.lang.NoClassDefFoundError:
> groovyx/net/http/HttpResponseException
> Class: Unknown
>
> -
>
> My code is as follows:
>
> -
>    def pricepoints = {
>
>        def priceLookUp = new PriceLookUp(customerKey: params.customerKey,
> countryCode: params.countryCode, currency: params.currency)
>
>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>        request = request + "\n" + (priceLookUp.generateXML())
>
>        def urlString =
> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>
>        def http = new HTTPBuilder(urlString)
>
>        http.request(POST, XML){
>            //delegate.contentType = "text/plain"
>            //delegate.headers['Content-Type'] = "text/xml"
>            delegate.body = request
>        }
>        println resp.statusCode
>
>
>    }
> -
>
> Tom Nichols wrote:
>>
>> Should have mentioned -- while the example shows an using an XML
>> builder, you should be able to pass your string writer as-is like so:
>>
>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>
>> def resp = http.request( POST, XML ) {
>>   body = someStringWriterThatWillOutputXML
>> }
>>
>> println resp.statusCode
>>
>>
>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<tmnichols@gmail.com> wrote:
>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>
>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<shaun@zong.com> wrote:
>>>>
>>>> Hello all,
>>>>
>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>> through
>>>> a HTTP post request as a parameter.
>>>>
>>>> I have been googling for the entire morning/afternoon and still can't
>>>> get it
>>>> to work. Any ideas, people?
>>>>
>>>> Sorry, I'm very very new to grails/groovy.
>>>>
>>>> Cheers
>>>> Shaun
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Well you don't need a folder 'http-builder' folder in the lib dir.
The -all.zip is simply to allow downloaded documentation, source code,
etc.  The only thing you need in order to _use_ HTTP Builder is the
JAR.  So I suppose that could be causing some problem, although that
sounds like a long shot.

Did you happen to open the JAR using a Zip-file extractor in order to
verify that the class indeed exists?  Again, this is pretty much a
sanity check, but at least narrows it down to some sort of classpath
issue.

-Tom


2009/8/19 ShaunLim <[hidden email]>:

>
> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1 folder"
> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
> residing in the "lib" directory of my project directory.
>
> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm just
> about tearing my hair out.
>
>
> Tom Nichols wrote:
>>
>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>> a sanity check, open the http-builder JAR and you should see
>> groovyx/net/http/HttpResponseException.class.  I believe this class
>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>> HTTP-Builder JAR somewhere on your classpath?
>>
>> -Tom
>>
>>
>> 2009/8/19 ShaunLim <[hidden email]>:
>>>
>>> Thanks Tom for the help. I am getting this error msg though:
>>>
>>> -
>>>
>>> Error 500: java.lang.NoClassDefFoundError:
>>> groovyx/net/http/HttpResponseException
>>> Servlet: grails
>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>> Exception Message: groovyx.net.http.HttpResponseException
>>> Caused by: java.lang.NoClassDefFoundError:
>>> groovyx/net/http/HttpResponseException
>>> Class: Unknown
>>>
>>> -
>>>
>>> My code is as follows:
>>>
>>> -
>>>    def pricepoints = {
>>>
>>>        def priceLookUp = new PriceLookUp(customerKey: params.customerKey,
>>> countryCode: params.countryCode, currency: params.currency)
>>>
>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>
>>>        def urlString =
>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>
>>>        def http = new HTTPBuilder(urlString)
>>>
>>>        http.request(POST, XML){
>>>            //delegate.contentType = "text/plain"
>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>            delegate.body = request
>>>        }
>>>        println resp.statusCode
>>>
>>>
>>>    }
>>> -
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Should have mentioned -- while the example shows an using an XML
>>>> builder, you should be able to pass your string writer as-is like so:
>>>>
>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>
>>>> def resp = http.request( POST, XML ) {
>>>>   body = someStringWriterThatWillOutputXML
>>>> }
>>>>
>>>> println resp.statusCode
>>>>
>>>>
>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]> wrote:
>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>
>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>>>> through
>>>>>> a HTTP post request as a parameter.
>>>>>>
>>>>>> I have been googling for the entire morning/afternoon and still can't
>>>>>> get it
>>>>>> to work. Any ideas, people?
>>>>>>
>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>
>>>>>> Cheers
>>>>>> Shaun
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

shaun lim jin
Yes, I opened it with WinRAR and saw the whole list of classes there, including HttpResponseException.

I've also deleted everything else in the folder, still no joy.

Tom Nichols wrote
Well you don't need a folder 'http-builder' folder in the lib dir.
The -all.zip is simply to allow downloaded documentation, source code,
etc.  The only thing you need in order to _use_ HTTP Builder is the
JAR.  So I suppose that could be causing some problem, although that
sounds like a long shot.

Did you happen to open the JAR using a Zip-file extractor in order to
verify that the class indeed exists?  Again, this is pretty much a
sanity check, but at least narrows it down to some sort of classpath
issue.

-Tom


2009/8/19 ShaunLim <shaun@zong.com>:
>
> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1 folder"
> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
> residing in the "lib" directory of my project directory.
>
> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm just
> about tearing my hair out.
>
>
> Tom Nichols wrote:
>>
>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>> a sanity check, open the http-builder JAR and you should see
>> groovyx/net/http/HttpResponseException.class.  I believe this class
>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>> HTTP-Builder JAR somewhere on your classpath?
>>
>> -Tom
>>
>>
>> 2009/8/19 ShaunLim <shaun@zong.com>:
>>>
>>> Thanks Tom for the help. I am getting this error msg though:
>>>
>>> -
>>>
>>> Error 500: java.lang.NoClassDefFoundError:
>>> groovyx/net/http/HttpResponseException
>>> Servlet: grails
>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>> Exception Message: groovyx.net.http.HttpResponseException
>>> Caused by: java.lang.NoClassDefFoundError:
>>> groovyx/net/http/HttpResponseException
>>> Class: Unknown
>>>
>>> -
>>>
>>> My code is as follows:
>>>
>>> -
>>>    def pricepoints = {
>>>
>>>        def priceLookUp = new PriceLookUp(customerKey: params.customerKey,
>>> countryCode: params.countryCode, currency: params.currency)
>>>
>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>
>>>        def urlString =
>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>
>>>        def http = new HTTPBuilder(urlString)
>>>
>>>        http.request(POST, XML){
>>>            //delegate.contentType = "text/plain"
>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>            delegate.body = request
>>>        }
>>>        println resp.statusCode
>>>
>>>
>>>    }
>>> -
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Should have mentioned -- while the example shows an using an XML
>>>> builder, you should be able to pass your string writer as-is like so:
>>>>
>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>
>>>> def resp = http.request( POST, XML ) {
>>>>   body = someStringWriterThatWillOutputXML
>>>> }
>>>>
>>>> println resp.statusCode
>>>>
>>>>
>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<tmnichols@gmail.com> wrote:
>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>
>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<shaun@zong.com> wrote:
>>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>>>> through
>>>>>> a HTTP post request as a parameter.
>>>>>>
>>>>>> I have been googling for the entire morning/afternoon and still can't
>>>>>> get it
>>>>>> to work. Any ideas, people?
>>>>>>
>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>
>>>>>> Cheers
>>>>>> Shaun
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Make sure you "grails clean" after deleting that folder.  Also, this
bit of code should serve as another sanity check:

import groovyx.net.http.*

@Grab(group='org.codehaus.groovy.modules.http-builder',
module='http-builder', version='0.5.0-RC1')
def dummy() {}

new HTTPBuilder('http://www.google.com/asdf').get([:])

Save it and run it like so:
tnichols@tnichols ~/Desktop
$ groovy test.groovy
Caught: groovyx.net.http.HttpResponseException: Not Found
        at test.run(test.groovy:6)

It will take a long time to run the first time because Ivy/Grape will
be downloading a boatload of JARs.

Unfortunately, without more insight into your environment, I can't
imagine where the classpath issue is coming from.  All I can do is
assert that it's some problem in your environment :|

Sorry I can't be of more help.
-Tom


On Wed, Aug 19, 2009 at 2:48 PM, ShaunLim<[hidden email]> wrote:

>
> Yes, I opened it with WinRAR and saw the whole list of classes there,
> including HttpResponseException.
>
> I've also deleted everything else in the folder, still no joy.
>
>
> Tom Nichols wrote:
>>
>> Well you don't need a folder 'http-builder' folder in the lib dir.
>> The -all.zip is simply to allow downloaded documentation, source code,
>> etc.  The only thing you need in order to _use_ HTTP Builder is the
>> JAR.  So I suppose that could be causing some problem, although that
>> sounds like a long shot.
>>
>> Did you happen to open the JAR using a Zip-file extractor in order to
>> verify that the class indeed exists?  Again, this is pretty much a
>> sanity check, but at least narrows it down to some sort of classpath
>> issue.
>>
>> -Tom
>>
>>
>> 2009/8/19 ShaunLim <[hidden email]>:
>>>
>>> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1 folder"
>>> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
>>> residing in the "lib" directory of my project directory.
>>>
>>> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm
>>> just
>>> about tearing my hair out.
>>>
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>>>> a sanity check, open the http-builder JAR and you should see
>>>> groovyx/net/http/HttpResponseException.class.  I believe this class
>>>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>>>> HTTP-Builder JAR somewhere on your classpath?
>>>>
>>>> -Tom
>>>>
>>>>
>>>> 2009/8/19 ShaunLim <[hidden email]>:
>>>>>
>>>>> Thanks Tom for the help. I am getting this error msg though:
>>>>>
>>>>> -
>>>>>
>>>>> Error 500: java.lang.NoClassDefFoundError:
>>>>> groovyx/net/http/HttpResponseException
>>>>> Servlet: grails
>>>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>>>> Exception Message: groovyx.net.http.HttpResponseException
>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>> groovyx/net/http/HttpResponseException
>>>>> Class: Unknown
>>>>>
>>>>> -
>>>>>
>>>>> My code is as follows:
>>>>>
>>>>> -
>>>>>    def pricepoints = {
>>>>>
>>>>>        def priceLookUp = new PriceLookUp(customerKey:
>>>>> params.customerKey,
>>>>> countryCode: params.countryCode, currency: params.currency)
>>>>>
>>>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>>>
>>>>>        def urlString =
>>>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>>>
>>>>>        def http = new HTTPBuilder(urlString)
>>>>>
>>>>>        http.request(POST, XML){
>>>>>            //delegate.contentType = "text/plain"
>>>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>>>            delegate.body = request
>>>>>        }
>>>>>        println resp.statusCode
>>>>>
>>>>>
>>>>>    }
>>>>> -
>>>>>
>>>>> Tom Nichols wrote:
>>>>>>
>>>>>> Should have mentioned -- while the example shows an using an XML
>>>>>> builder, you should be able to pass your string writer as-is like so:
>>>>>>
>>>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>>>
>>>>>> def resp = http.request( POST, XML ) {
>>>>>>   body = someStringWriterThatWillOutputXML
>>>>>> }
>>>>>>
>>>>>> println resp.statusCode
>>>>>>
>>>>>>
>>>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]>
>>>>>> wrote:
>>>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>>>
>>>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>>>>>> through
>>>>>>>> a HTTP post request as a parameter.
>>>>>>>>
>>>>>>>> I have been googling for the entire morning/afternoon and still
>>>>>>>> can't
>>>>>>>> get it
>>>>>>>> to work. Any ideas, people?
>>>>>>>>
>>>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>>>
>>>>>>>> Cheers
>>>>>>>> Shaun
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25049795.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

shaun lim jin
Hey Tom,

Thanks for all your patient replies. It's really strange how groovy looks for the APACHE HttpResponseException class and not the one that comes with httpbuilder!

C:\Users\Shaun>groovy test.groovy
Caught: java.lang.NoClassDefFoundError: org/apache/http/client/HttpResponseExcep
tion
        at test.class$(test.groovy)
        at test.$get$$class$groovyx$net$http$HTTPBuilder(test.groovy)
        at test.run(test.groovy:7)

C:\Users\Shaun>

-Shaun

Tom Nichols wrote
Make sure you "grails clean" after deleting that folder.  Also, this
bit of code should serve as another sanity check:

import groovyx.net.http.*

@Grab(group='org.codehaus.groovy.modules.http-builder',
module='http-builder', version='0.5.0-RC1')
def dummy() {}

new HTTPBuilder('http://www.google.com/asdf').get([:])

Save it and run it like so:
tnichols@tnichols ~/Desktop
$ groovy test.groovy
Caught: groovyx.net.http.HttpResponseException: Not Found
        at test.run(test.groovy:6)

It will take a long time to run the first time because Ivy/Grape will
be downloading a boatload of JARs.

Unfortunately, without more insight into your environment, I can't
imagine where the classpath issue is coming from.  All I can do is
assert that it's some problem in your environment :|

Sorry I can't be of more help.
-Tom


On Wed, Aug 19, 2009 at 2:48 PM, ShaunLim<shaun@zong.com> wrote:
>
> Yes, I opened it with WinRAR and saw the whole list of classes there,
> including HttpResponseException.
>
> I've also deleted everything else in the folder, still no joy.
>
>
> Tom Nichols wrote:
>>
>> Well you don't need a folder 'http-builder' folder in the lib dir.
>> The -all.zip is simply to allow downloaded documentation, source code,
>> etc.  The only thing you need in order to _use_ HTTP Builder is the
>> JAR.  So I suppose that could be causing some problem, although that
>> sounds like a long shot.
>>
>> Did you happen to open the JAR using a Zip-file extractor in order to
>> verify that the class indeed exists?  Again, this is pretty much a
>> sanity check, but at least narrows it down to some sort of classpath
>> issue.
>>
>> -Tom
>>
>>
>> 2009/8/19 ShaunLim <shaun@zong.com>:
>>>
>>> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1 folder"
>>> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
>>> residing in the "lib" directory of my project directory.
>>>
>>> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm
>>> just
>>> about tearing my hair out.
>>>
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>>>> a sanity check, open the http-builder JAR and you should see
>>>> groovyx/net/http/HttpResponseException.class.  I believe this class
>>>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>>>> HTTP-Builder JAR somewhere on your classpath?
>>>>
>>>> -Tom
>>>>
>>>>
>>>> 2009/8/19 ShaunLim <shaun@zong.com>:
>>>>>
>>>>> Thanks Tom for the help. I am getting this error msg though:
>>>>>
>>>>> -
>>>>>
>>>>> Error 500: java.lang.NoClassDefFoundError:
>>>>> groovyx/net/http/HttpResponseException
>>>>> Servlet: grails
>>>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>>>> Exception Message: groovyx.net.http.HttpResponseException
>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>> groovyx/net/http/HttpResponseException
>>>>> Class: Unknown
>>>>>
>>>>> -
>>>>>
>>>>> My code is as follows:
>>>>>
>>>>> -
>>>>>    def pricepoints = {
>>>>>
>>>>>        def priceLookUp = new PriceLookUp(customerKey:
>>>>> params.customerKey,
>>>>> countryCode: params.countryCode, currency: params.currency)
>>>>>
>>>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>>>
>>>>>        def urlString =
>>>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>>>
>>>>>        def http = new HTTPBuilder(urlString)
>>>>>
>>>>>        http.request(POST, XML){
>>>>>            //delegate.contentType = "text/plain"
>>>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>>>            delegate.body = request
>>>>>        }
>>>>>        println resp.statusCode
>>>>>
>>>>>
>>>>>    }
>>>>> -
>>>>>
>>>>> Tom Nichols wrote:
>>>>>>
>>>>>> Should have mentioned -- while the example shows an using an XML
>>>>>> builder, you should be able to pass your string writer as-is like so:
>>>>>>
>>>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>>>
>>>>>> def resp = http.request( POST, XML ) {
>>>>>>   body = someStringWriterThatWillOutputXML
>>>>>> }
>>>>>>
>>>>>> println resp.statusCode
>>>>>>
>>>>>>
>>>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<tmnichols@gmail.com>
>>>>>> wrote:
>>>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>>>
>>>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<shaun@zong.com> wrote:
>>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> I'm trying to pass a StringWriter instance containing a block of XML
>>>>>>>> through
>>>>>>>> a HTTP post request as a parameter.
>>>>>>>>
>>>>>>>> I have been googling for the entire morning/afternoon and still
>>>>>>>> can't
>>>>>>>> get it
>>>>>>>> to work. Any ideas, people?
>>>>>>>>
>>>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>>>
>>>>>>>> Cheers
>>>>>>>> Shaun
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25049795.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
No, that's acceptable, because my HttpResponseException is a subclass
of Apache's.  But if you ran that script with the @Grab annotation, it
should have downloaded the Apache HttpClient dependency as well.  In
fact, if you got that far, it _must_ have downloaded that JAR,
otherwise you would have gotten a bunch of other
ClassNotFoundExceptions before that one.  So I'm still confused.

-Tom


On Thu, Aug 20, 2009 at 12:37 PM, ShaunLim<[hidden email]> wrote:

>
> Hey Tom,
>
> Thanks for all your patient replies. It's really strange how groovy looks
> for the APACHE HttpResponseException class and not the one that comes with
> httpbuilder!
>
> C:\Users\Shaun>groovy test.groovy
> Caught: java.lang.NoClassDefFoundError:
> org/apache/http/client/HttpResponseExcep
> tion
>        at test.class$(test.groovy)
>        at test.$get$$class$groovyx$net$http$HTTPBuilder(test.groovy)
>        at test.run(test.groovy:7)
>
> C:\Users\Shaun>
>
> -Shaun
>
>
> Tom Nichols wrote:
>>
>> Make sure you "grails clean" after deleting that folder.  Also, this
>> bit of code should serve as another sanity check:
>>
>> import groovyx.net.http.*
>>
>> @Grab(group='org.codehaus.groovy.modules.http-builder',
>> module='http-builder', version='0.5.0-RC1')
>> def dummy() {}
>>
>> new HTTPBuilder('http://www.google.com/asdf').get([:])
>>
>> Save it and run it like so:
>> tnichols@tnichols ~/Desktop
>> $ groovy test.groovy
>> Caught: groovyx.net.http.HttpResponseException: Not Found
>>         at test.run(test.groovy:6)
>>
>> It will take a long time to run the first time because Ivy/Grape will
>> be downloading a boatload of JARs.
>>
>> Unfortunately, without more insight into your environment, I can't
>> imagine where the classpath issue is coming from.  All I can do is
>> assert that it's some problem in your environment :|
>>
>> Sorry I can't be of more help.
>> -Tom
>>
>>
>> On Wed, Aug 19, 2009 at 2:48 PM, ShaunLim<[hidden email]> wrote:
>>>
>>> Yes, I opened it with WinRAR and saw the whole list of classes there,
>>> including HttpResponseException.
>>>
>>> I've also deleted everything else in the folder, still no joy.
>>>
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Well you don't need a folder 'http-builder' folder in the lib dir.
>>>> The -all.zip is simply to allow downloaded documentation, source code,
>>>> etc.  The only thing you need in order to _use_ HTTP Builder is the
>>>> JAR.  So I suppose that could be causing some problem, although that
>>>> sounds like a long shot.
>>>>
>>>> Did you happen to open the JAR using a Zip-file extractor in order to
>>>> verify that the class indeed exists?  Again, this is pretty much a
>>>> sanity check, but at least narrows it down to some sort of classpath
>>>> issue.
>>>>
>>>> -Tom
>>>>
>>>>
>>>> 2009/8/19 ShaunLim <[hidden email]>:
>>>>>
>>>>> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1
>>>>> folder"
>>>>> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
>>>>> residing in the "lib" directory of my project directory.
>>>>>
>>>>> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm
>>>>> just
>>>>> about tearing my hair out.
>>>>>
>>>>>
>>>>> Tom Nichols wrote:
>>>>>>
>>>>>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>>>>>> a sanity check, open the http-builder JAR and you should see
>>>>>> groovyx/net/http/HttpResponseException.class.  I believe this class
>>>>>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>>>>>> HTTP-Builder JAR somewhere on your classpath?
>>>>>>
>>>>>> -Tom
>>>>>>
>>>>>>
>>>>>> 2009/8/19 ShaunLim <[hidden email]>:
>>>>>>>
>>>>>>> Thanks Tom for the help. I am getting this error msg though:
>>>>>>>
>>>>>>> -
>>>>>>>
>>>>>>> Error 500: java.lang.NoClassDefFoundError:
>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>> Servlet: grails
>>>>>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>>>>>> Exception Message: groovyx.net.http.HttpResponseException
>>>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>> Class: Unknown
>>>>>>>
>>>>>>> -
>>>>>>>
>>>>>>> My code is as follows:
>>>>>>>
>>>>>>> -
>>>>>>>    def pricepoints = {
>>>>>>>
>>>>>>>        def priceLookUp = new PriceLookUp(customerKey:
>>>>>>> params.customerKey,
>>>>>>> countryCode: params.countryCode, currency: params.currency)
>>>>>>>
>>>>>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>>>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>>>>>
>>>>>>>        def urlString =
>>>>>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>>>>>
>>>>>>>        def http = new HTTPBuilder(urlString)
>>>>>>>
>>>>>>>        http.request(POST, XML){
>>>>>>>            //delegate.contentType = "text/plain"
>>>>>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>>>>>            delegate.body = request
>>>>>>>        }
>>>>>>>        println resp.statusCode
>>>>>>>
>>>>>>>
>>>>>>>    }
>>>>>>> -
>>>>>>>
>>>>>>> Tom Nichols wrote:
>>>>>>>>
>>>>>>>> Should have mentioned -- while the example shows an using an XML
>>>>>>>> builder, you should be able to pass your string writer as-is like
>>>>>>>> so:
>>>>>>>>
>>>>>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>>>>>
>>>>>>>> def resp = http.request( POST, XML ) {
>>>>>>>>   body = someStringWriterThatWillOutputXML
>>>>>>>> }
>>>>>>>>
>>>>>>>> println resp.statusCode
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]>
>>>>>>>> wrote:
>>>>>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>>>>>
>>>>>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Hello all,
>>>>>>>>>>
>>>>>>>>>> I'm trying to pass a StringWriter instance containing a block of
>>>>>>>>>> XML
>>>>>>>>>> through
>>>>>>>>>> a HTTP post request as a parameter.
>>>>>>>>>>
>>>>>>>>>> I have been googling for the entire morning/afternoon and still
>>>>>>>>>> can't
>>>>>>>>>> get it
>>>>>>>>>> to work. Any ideas, people?
>>>>>>>>>>
>>>>>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>>>>>
>>>>>>>>>> Cheers
>>>>>>>>>> Shaun
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>
>>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25049795.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25065597.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

shaun lim jin
I am very confused as well. Do you think a fresh reinstall of the whole groovy/grails thing will work? It's really frustrating.

-Shaun

Tom Nichols wrote
No, that's acceptable, because my HttpResponseException is a subclass
of Apache's.  But if you ran that script with the @Grab annotation, it
should have downloaded the Apache HttpClient dependency as well.  In
fact, if you got that far, it _must_ have downloaded that JAR,
otherwise you would have gotten a bunch of other
ClassNotFoundExceptions before that one.  So I'm still confused.

-Tom


On Thu, Aug 20, 2009 at 12:37 PM, ShaunLim<shaun@zong.com> wrote:
>
> Hey Tom,
>
> Thanks for all your patient replies. It's really strange how groovy looks
> for the APACHE HttpResponseException class and not the one that comes with
> httpbuilder!
>
> C:\Users\Shaun>groovy test.groovy
> Caught: java.lang.NoClassDefFoundError:
> org/apache/http/client/HttpResponseExcep
> tion
>        at test.class$(test.groovy)
>        at test.$get$$class$groovyx$net$http$HTTPBuilder(test.groovy)
>        at test.run(test.groovy:7)
>
> C:\Users\Shaun>
>
> -Shaun
>
>
> Tom Nichols wrote:
>>
>> Make sure you "grails clean" after deleting that folder.  Also, this
>> bit of code should serve as another sanity check:
>>
>> import groovyx.net.http.*
>>
>> @Grab(group='org.codehaus.groovy.modules.http-builder',
>> module='http-builder', version='0.5.0-RC1')
>> def dummy() {}
>>
>> new HTTPBuilder('http://www.google.com/asdf').get([:])
>>
>> Save it and run it like so:
>> tnichols@tnichols ~/Desktop
>> $ groovy test.groovy
>> Caught: groovyx.net.http.HttpResponseException: Not Found
>>         at test.run(test.groovy:6)
>>
>> It will take a long time to run the first time because Ivy/Grape will
>> be downloading a boatload of JARs.
>>
>> Unfortunately, without more insight into your environment, I can't
>> imagine where the classpath issue is coming from.  All I can do is
>> assert that it's some problem in your environment :|
>>
>> Sorry I can't be of more help.
>> -Tom
>>
>>
>> On Wed, Aug 19, 2009 at 2:48 PM, ShaunLim<shaun@zong.com> wrote:
>>>
>>> Yes, I opened it with WinRAR and saw the whole list of classes there,
>>> including HttpResponseException.
>>>
>>> I've also deleted everything else in the folder, still no joy.
>>>
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Well you don't need a folder 'http-builder' folder in the lib dir.
>>>> The -all.zip is simply to allow downloaded documentation, source code,
>>>> etc.  The only thing you need in order to _use_ HTTP Builder is the
>>>> JAR.  So I suppose that could be causing some problem, although that
>>>> sounds like a long shot.
>>>>
>>>> Did you happen to open the JAR using a Zip-file extractor in order to
>>>> verify that the class indeed exists?  Again, this is pretty much a
>>>> sanity check, but at least narrows it down to some sort of classpath
>>>> issue.
>>>>
>>>> -Tom
>>>>
>>>>
>>>> 2009/8/19 ShaunLim <shaun@zong.com>:
>>>>>
>>>>> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1
>>>>> folder"
>>>>> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are all
>>>>> residing in the "lib" directory of my project directory.
>>>>>
>>>>> And no, I do not have 0.4.x anywhere. Thanks so much for your help; I'm
>>>>> just
>>>>> about tearing my hair out.
>>>>>
>>>>>
>>>>> Tom Nichols wrote:
>>>>>>
>>>>>> Well, NoClassDefFoundError usually indicates a classpath problem.  As
>>>>>> a sanity check, open the http-builder JAR and you should see
>>>>>> groovyx/net/http/HttpResponseException.class.  I believe this class
>>>>>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>>>>>> HTTP-Builder JAR somewhere on your classpath?
>>>>>>
>>>>>> -Tom
>>>>>>
>>>>>>
>>>>>> 2009/8/19 ShaunLim <shaun@zong.com>:
>>>>>>>
>>>>>>> Thanks Tom for the help. I am getting this error msg though:
>>>>>>>
>>>>>>> -
>>>>>>>
>>>>>>> Error 500: java.lang.NoClassDefFoundError:
>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>> Servlet: grails
>>>>>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>>>>>> Exception Message: groovyx.net.http.HttpResponseException
>>>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>> Class: Unknown
>>>>>>>
>>>>>>> -
>>>>>>>
>>>>>>> My code is as follows:
>>>>>>>
>>>>>>> -
>>>>>>>    def pricepoints = {
>>>>>>>
>>>>>>>        def priceLookUp = new PriceLookUp(customerKey:
>>>>>>> params.customerKey,
>>>>>>> countryCode: params.countryCode, currency: params.currency)
>>>>>>>
>>>>>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>>>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>>>>>
>>>>>>>        def urlString =
>>>>>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>>>>>
>>>>>>>        def http = new HTTPBuilder(urlString)
>>>>>>>
>>>>>>>        http.request(POST, XML){
>>>>>>>            //delegate.contentType = "text/plain"
>>>>>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>>>>>            delegate.body = request
>>>>>>>        }
>>>>>>>        println resp.statusCode
>>>>>>>
>>>>>>>
>>>>>>>    }
>>>>>>> -
>>>>>>>
>>>>>>> Tom Nichols wrote:
>>>>>>>>
>>>>>>>> Should have mentioned -- while the example shows an using an XML
>>>>>>>> builder, you should be able to pass your string writer as-is like
>>>>>>>> so:
>>>>>>>>
>>>>>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>>>>>
>>>>>>>> def resp = http.request( POST, XML ) {
>>>>>>>>   body = someStringWriterThatWillOutputXML
>>>>>>>> }
>>>>>>>>
>>>>>>>> println resp.statusCode
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<tmnichols@gmail.com>
>>>>>>>> wrote:
>>>>>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>>>>>
>>>>>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<shaun@zong.com> wrote:
>>>>>>>>>>
>>>>>>>>>> Hello all,
>>>>>>>>>>
>>>>>>>>>> I'm trying to pass a StringWriter instance containing a block of
>>>>>>>>>> XML
>>>>>>>>>> through
>>>>>>>>>> a HTTP post request as a parameter.
>>>>>>>>>>
>>>>>>>>>> I have been googling for the entire morning/afternoon and still
>>>>>>>>>> can't
>>>>>>>>>> get it
>>>>>>>>>> to work. Any ideas, people?
>>>>>>>>>>
>>>>>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>>>>>
>>>>>>>>>> Cheers
>>>>>>>>>> Shaun
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>
>>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25049795.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25065597.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Hi Shaun,

Are you still working on this?  Yes, reinstalling things might be the
last resort needed.  I'm still confused as to why you could be seeing
these errors.  What Groovy version are you running?

Do you have a CLASSPATH system variable set that could be getting in the way?
Do you have anything in ~/.groovy/ that is manipulating the classpath
in any way?

The fact that you can't seem to run a simple groovy script with a
@Grab annotation is very troubling.  Can you reproduce the same
problem on another machine?

-Tom

On Thu, Aug 20, 2009 at 1:27 PM, ShaunLim<[hidden email]> wrote:

>
> I am very confused as well. Do you think a fresh reinstall of the whole
> groovy/grails thing will work? It's really frustrating.
>
> -Shaun
>
>
> Tom Nichols wrote:
>>
>> No, that's acceptable, because my HttpResponseException is a subclass
>> of Apache's.  But if you ran that script with the @Grab annotation, it
>> should have downloaded the Apache HttpClient dependency as well.  In
>> fact, if you got that far, it _must_ have downloaded that JAR,
>> otherwise you would have gotten a bunch of other
>> ClassNotFoundExceptions before that one.  So I'm still confused.
>>
>> -Tom
>>
>>
>> On Thu, Aug 20, 2009 at 12:37 PM, ShaunLim<[hidden email]> wrote:
>>>
>>> Hey Tom,
>>>
>>> Thanks for all your patient replies. It's really strange how groovy looks
>>> for the APACHE HttpResponseException class and not the one that comes
>>> with
>>> httpbuilder!
>>>
>>> C:\Users\Shaun>groovy test.groovy
>>> Caught: java.lang.NoClassDefFoundError:
>>> org/apache/http/client/HttpResponseExcep
>>> tion
>>>        at test.class$(test.groovy)
>>>        at test.$get$$class$groovyx$net$http$HTTPBuilder(test.groovy)
>>>        at test.run(test.groovy:7)
>>>
>>> C:\Users\Shaun>
>>>
>>> -Shaun
>>>
>>>
>>> Tom Nichols wrote:
>>>>
>>>> Make sure you "grails clean" after deleting that folder.  Also, this
>>>> bit of code should serve as another sanity check:
>>>>
>>>> import groovyx.net.http.*
>>>>
>>>> @Grab(group='org.codehaus.groovy.modules.http-builder',
>>>> module='http-builder', version='0.5.0-RC1')
>>>> def dummy() {}
>>>>
>>>> new HTTPBuilder('http://www.google.com/asdf').get([:])
>>>>
>>>> Save it and run it like so:
>>>> tnichols@tnichols ~/Desktop
>>>> $ groovy test.groovy
>>>> Caught: groovyx.net.http.HttpResponseException: Not Found
>>>>         at test.run(test.groovy:6)
>>>>
>>>> It will take a long time to run the first time because Ivy/Grape will
>>>> be downloading a boatload of JARs.
>>>>
>>>> Unfortunately, without more insight into your environment, I can't
>>>> imagine where the classpath issue is coming from.  All I can do is
>>>> assert that it's some problem in your environment :|
>>>>
>>>> Sorry I can't be of more help.
>>>> -Tom
>>>>
>>>>
>>>> On Wed, Aug 19, 2009 at 2:48 PM, ShaunLim<[hidden email]> wrote:
>>>>>
>>>>> Yes, I opened it with WinRAR and saw the whole list of classes there,
>>>>> including HttpResponseException.
>>>>>
>>>>> I've also deleted everything else in the folder, still no joy.
>>>>>
>>>>>
>>>>> Tom Nichols wrote:
>>>>>>
>>>>>> Well you don't need a folder 'http-builder' folder in the lib dir.
>>>>>> The -all.zip is simply to allow downloaded documentation, source code,
>>>>>> etc.  The only thing you need in order to _use_ HTTP Builder is the
>>>>>> JAR.  So I suppose that could be causing some problem, although that
>>>>>> sounds like a long shot.
>>>>>>
>>>>>> Did you happen to open the JAR using a Zip-file extractor in order to
>>>>>> verify that the class indeed exists?  Again, this is pretty much a
>>>>>> sanity check, but at least narrows it down to some sort of classpath
>>>>>> issue.
>>>>>>
>>>>>> -Tom
>>>>>>
>>>>>>
>>>>>> 2009/8/19 ShaunLim <[hidden email]>:
>>>>>>>
>>>>>>> I have "http-builder-0.5.0-RC1.jar" and a "http-builder-0.5.0-RC1
>>>>>>> folder"
>>>>>>> that was extracted from "http-builder-0.5.0-RC1-all.zip". These are
>>>>>>> all
>>>>>>> residing in the "lib" directory of my project directory.
>>>>>>>
>>>>>>> And no, I do not have 0.4.x anywhere. Thanks so much for your help;
>>>>>>> I'm
>>>>>>> just
>>>>>>> about tearing my hair out.
>>>>>>>
>>>>>>>
>>>>>>> Tom Nichols wrote:
>>>>>>>>
>>>>>>>> Well, NoClassDefFoundError usually indicates a classpath problem.
>>>>>>>>  As
>>>>>>>> a sanity check, open the http-builder JAR and you should see
>>>>>>>> groovyx/net/http/HttpResponseException.class.  I believe this class
>>>>>>>> was introduced in 0.5.0 -- is it possible you have a 0.4.x
>>>>>>>> HTTP-Builder JAR somewhere on your classpath?
>>>>>>>>
>>>>>>>> -Tom
>>>>>>>>
>>>>>>>>
>>>>>>>> 2009/8/19 ShaunLim <[hidden email]>:
>>>>>>>>>
>>>>>>>>> Thanks Tom for the help. I am getting this error msg though:
>>>>>>>>>
>>>>>>>>> -
>>>>>>>>>
>>>>>>>>> Error 500: java.lang.NoClassDefFoundError:
>>>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>>>> Servlet: grails
>>>>>>>>> URI: /ZongTest/grails/oneOff/pricepoints.dispatch
>>>>>>>>> Exception Message: groovyx.net.http.HttpResponseException
>>>>>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>>>>>> groovyx/net/http/HttpResponseException
>>>>>>>>> Class: Unknown
>>>>>>>>>
>>>>>>>>> -
>>>>>>>>>
>>>>>>>>> My code is as follows:
>>>>>>>>>
>>>>>>>>> -
>>>>>>>>>    def pricepoints = {
>>>>>>>>>
>>>>>>>>>        def priceLookUp = new PriceLookUp(customerKey:
>>>>>>>>> params.customerKey,
>>>>>>>>> countryCode: params.countryCode, currency: params.currency)
>>>>>>>>>
>>>>>>>>>        def request = '<?xml version="1.0" encoding="UTF-8"?>'
>>>>>>>>>        request = request + "\n" + (priceLookUp.generateXML())
>>>>>>>>>
>>>>>>>>>        def urlString =
>>>>>>>>> "http://apps.zong.com/zong-cash/actions/default?method=lookup"
>>>>>>>>>
>>>>>>>>>        def http = new HTTPBuilder(urlString)
>>>>>>>>>
>>>>>>>>>        http.request(POST, XML){
>>>>>>>>>            //delegate.contentType = "text/plain"
>>>>>>>>>            //delegate.headers['Content-Type'] = "text/xml"
>>>>>>>>>            delegate.body = request
>>>>>>>>>        }
>>>>>>>>>        println resp.statusCode
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    }
>>>>>>>>> -
>>>>>>>>>
>>>>>>>>> Tom Nichols wrote:
>>>>>>>>>>
>>>>>>>>>> Should have mentioned -- while the example shows an using an XML
>>>>>>>>>> builder, you should be able to pass your string writer as-is like
>>>>>>>>>> so:
>>>>>>>>>>
>>>>>>>>>> def http = new HTTPBuilder( 'http://localhost:8080/myApp/' )
>>>>>>>>>>
>>>>>>>>>> def resp = http.request( POST, XML ) {
>>>>>>>>>>   body = someStringWriterThatWillOutputXML
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> println resp.statusCode
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wed, Aug 19, 2009 at 9:52 AM, Tom Nichols<[hidden email]>
>>>>>>>>>> wrote:
>>>>>>>>>>> See http://groovy.codehaus.org/modules/http-builder/doc/xml.html
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Aug 18, 2009 at 7:18 PM, ShaunLim<[hidden email]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hello all,
>>>>>>>>>>>>
>>>>>>>>>>>> I'm trying to pass a StringWriter instance containing a block of
>>>>>>>>>>>> XML
>>>>>>>>>>>> through
>>>>>>>>>>>> a HTTP post request as a parameter.
>>>>>>>>>>>>
>>>>>>>>>>>> I have been googling for the entire morning/afternoon and still
>>>>>>>>>>>> can't
>>>>>>>>>>>> get it
>>>>>>>>>>>> to work. Any ideas, people?
>>>>>>>>>>>>
>>>>>>>>>>>> Sorry, I'm very very new to grails/groovy.
>>>>>>>>>>>>
>>>>>>>>>>>> Cheers
>>>>>>>>>>>> Shaun
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25035216.html
>>>>>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>>>
>>>>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>
>>>>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25047172.html
>>>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>
>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25048713.html
>>>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25049795.html
>>>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25065597.html
>>> Sent from the groovy - user mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25066448.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Christian Näger
Well, I can reproduce it here :-(
I have a fresh grails install, a new (empty) grails application, I start up the grails console and enter the following code:

import groovyx.net.http.*

def http = new HTTPBuilder('http://www.google.com')
   
   http.get( path : '/search',
             contentType : TEXT,
             query : [q:'Groovy'] ) { resp, reader ->
     println "response status: ${resp.statusLine}"
     println 'Response data: -----'
     System.out << reader
     println '\n--------------------'
   }

When I don't have http-builder-0.5.0-RC1.jar in the lib directory of my grails app, groovy complains about HTTPBuilder. If I do have http-builder-0.5.0-RC1.jar in the lib, groovy complains about

java.lang.NoClassDefFoundError: groovyx/net/http/HttpResponseException

Which is odd, cause HTTPBuilder.class is obviously taken from the jar and HttpResponseException.class is right there too (when opening the jar with winzip). Haven't changed my classpath at all:

$ echo $CLASSPATH
.;C:\Programme\Java\jre6\lib\ext\QTJava.zip

Any idea what's going wrong?

Thanks, Chris

PS: The @Grab doesn't work cause I am to dumb to make that work with my company's proxy (I think).

Tom Nichols wrote
Hi Shaun,

Are you still working on this?  Yes, reinstalling things might be the
last resort needed.  I'm still confused as to why you could be seeing
these errors.  What Groovy version are you running?

Do you have a CLASSPATH system variable set that could be getting in the way?
Do you have anything in ~/.groovy/ that is manipulating the classpath
in any way?

The fact that you can't seem to run a simple groovy script with a
@Grab annotation is very troubling.  Can you reproduce the same
problem on another machine?

-Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Christian Näger
Well, it does work now, but I had to manually place the following libs into the libs directory of my grails app:

$ ll
total 1036
drwx------+  2 Naeger mkgroup      0 Sep  9 13:31 ./
drwx------+ 10 Naeger mkgroup      0 Sep  9 13:30 ../
-rwx------+  1 Naeger mkgroup 135538 Sep  9 10:04 http-builder-0.5.0-RC1.jar*
-rwx------+  1 Naeger mkgroup 289954 Aug  6 22:14 httpclient-4.0.jar*
-rwx------+  1 Naeger mkgroup 172888 Jun 18 20:17 httpcore-4.0.1.jar*
-rwx------+  1 Naeger mkgroup 180424 Jun 18 20:18 httpcore-nio-4.0.1.jar*
-rwx------+  1 Naeger mkgroup  25993 Aug  6 22:14 httpmime-4.0.jar*
-rwx------+  1 Naeger mkgroup 151839 Sep  9 13:18 json-lib-2.3-jdk15.jar*
-rwx------+  1 Naeger mkgroup  84091 Nov 20  2006 resolver.jar*

Regards, Chris

Christian Näger wrote
Well, I can reproduce it here :-(
I have a fresh grails install, a new (empty) grails application, I start up the grails console and enter the following code:

import groovyx.net.http.*

def http = new HTTPBuilder('http://www.google.com')
   
   http.get( path : '/search',
             contentType : TEXT,
             query : [q:'Groovy'] ) { resp, reader ->
     println "response status: ${resp.statusLine}"
     println 'Response data: -----'
     System.out << reader
     println '\n--------------------'
   }

When I don't have http-builder-0.5.0-RC1.jar in the lib directory of my grails app, groovy complains about HTTPBuilder. If I do have http-builder-0.5.0-RC1.jar in the lib, groovy complains about

java.lang.NoClassDefFoundError: groovyx/net/http/HttpResponseException

Which is odd, cause HTTPBuilder.class is obviously taken from the jar and HttpResponseException.class is right there too (when opening the jar with winzip). Haven't changed my classpath at all:

$ echo $CLASSPATH
.;C:\Programme\Java\jre6\lib\ext\QTJava.zip

Any idea what's going wrong?

Thanks, Chris

PS: The @Grab doesn't work cause I am to dumb to make that work with my company's proxy (I think).

Tom Nichols wrote
Hi Shaun,

Are you still working on this?  Yes, reinstalling things might be the
last resort needed.  I'm still confused as to why you could be seeing
these errors.  What Groovy version are you running?

Do you have a CLASSPATH system variable set that could be getting in the way?
Do you have anything in ~/.groovy/ that is manipulating the classpath
in any way?

The fact that you can't seem to run a simple groovy script with a
@Grab annotation is very troubling.  Can you reproduce the same
problem on another machine?

-Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Posting a XML parameter through HTTP Post request

Thom Nichols
Yeah that looks about right.  If you download one of the packages on
Maven (e.g. the .gz or .zip files here:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.0-SNAPSHOT/
) it will have all of the JAR dependencies included.  Maybe it was
httpcore that was missing?  Glad you were able to figure it out.

On Wed, Sep 9, 2009 at 7:43 AM, Christian Näger <[hidden email]> wrote:

>
> Well, it does work now, but I had to manually place the following libs into
> the libs directory of my grails app:
>
> $ ll
> total 1036
> drwx------+  2 Naeger mkgroup      0 Sep  9 13:31 ./
> drwx------+ 10 Naeger mkgroup      0 Sep  9 13:30 ../
> -rwx------+  1 Naeger mkgroup 135538 Sep  9 10:04
> http-builder-0.5.0-RC1.jar*
> -rwx------+  1 Naeger mkgroup 289954 Aug  6 22:14 httpclient-4.0.jar*
> -rwx------+  1 Naeger mkgroup 172888 Jun 18 20:17 httpcore-4.0.1.jar*
> -rwx------+  1 Naeger mkgroup 180424 Jun 18 20:18 httpcore-nio-4.0.1.jar*
> -rwx------+  1 Naeger mkgroup  25993 Aug  6 22:14 httpmime-4.0.jar*
> -rwx------+  1 Naeger mkgroup 151839 Sep  9 13:18 json-lib-2.3-jdk15.jar*
> -rwx------+  1 Naeger mkgroup  84091 Nov 20  2006 resolver.jar*
>
> Regards, Chris
>
>
> Christian Näger wrote:
>>
>> Well, I can reproduce it here :-(
>> I have a fresh grails install, a new (empty) grails application, I start
>> up the grails console and enter the following code:
>>
>> import groovyx.net.http.*
>>
>> def http = new HTTPBuilder('http://www.google.com')
>>
>>    http.get( path : '/search',
>>              contentType : TEXT,
>>              query : [q:'Groovy'] ) { resp, reader ->
>>      println "response status: ${resp.statusLine}"
>>      println 'Response data: -----'
>>      System.out << reader
>>      println '\n--------------------'
>>    }
>>
>> When I don't have http-builder-0.5.0-RC1.jar in the lib directory of my
>> grails app, groovy complains about HTTPBuilder. If I do have
>> http-builder-0.5.0-RC1.jar in the lib, groovy complains about
>>
>> java.lang.NoClassDefFoundError: groovyx/net/http/HttpResponseException
>>
>> Which is odd, cause HTTPBuilder.class is obviously taken from the jar and
>> HttpResponseException.class is right there too (when opening the jar with
>> winzip). Haven't changed my classpath at all:
>>
>> $ echo $CLASSPATH
>> .;C:\Programme\Java\jre6\lib\ext\QTJava.zip
>>
>> Any idea what's going wrong?
>>
>> Thanks, Chris
>>
>> PS: The @Grab doesn't work cause I am to dumb to make that work with my
>> company's proxy (I think).
>>
>>
>> Tom Nichols wrote:
>>>
>>> Hi Shaun,
>>>
>>> Are you still working on this?  Yes, reinstalling things might be the
>>> last resort needed.  I'm still confused as to why you could be seeing
>>> these errors.  What Groovy version are you running?
>>>
>>> Do you have a CLASSPATH system variable set that could be getting in the
>>> way?
>>> Do you have anything in ~/.groovy/ that is manipulating the classpath
>>> in any way?
>>>
>>> The fact that you can't seem to run a simple groovy script with a
>>> @Grab annotation is very troubling.  Can you reproduce the same
>>> problem on another machine?
>>>
>>> -Tom
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Posting-a-XML-parameter-through-HTTP-Post-request-tp25035216p25363195.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...