Quantcast

Posting a XML parameter through HTTP Post request

classic Classic list List threaded Threaded
16 messages Options
12
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

12
Loading...