I've set contentType = 'text/xml' and with debugging I see the response XML 
coming back (with a , but

response.success = resp, xml ->
   println"XML was ${xml}"
   println "WsFindStemsResults was ${xml.WsFindStemsResults}"
}

just prints the data from the XML, all the tags are removed and  println 
"${xml.FirstElement}"   prints nothing.

Any ideas?

Debugging info:

[DEBUG] headers - << Content-Type: text/xml;charset=UTF-8
[DEBUG] headers - << Vary: Accept-Encoding
[DEBUG] headers - << Keep-Alive: timeout=5, max=99
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Transfer-Encoding: chunked
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
JSESSIONID][value: DF323AB24B8F2D4225AF09455EC7673B][domain: 
grouperdev.musc.edu][path: /grouper-ws][expiry: null]".
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] TargetAuthenticationStrategy - Caching 'basic' auth scheme for 
https://grouperdev.musc.edu:443
[DEBUG] wire - << "3fd[\r][\n]"
[DEBUG] wire - << 
"<WsFindStemsResults><stemResults><WsStem><idIndex>28841</idIndex><extension>IT</extension><displayExtension>INFORMATION
 
TECHNOLOGY</displayExtension><description></description><displayName>Test:Service
 Line Org Tree:MUSC University:INFORMATION 
TECHNOLOGY</displayName><name>Test:sa:UNIV:IT</name><uuid>b1e93a1f819a4090b97679cbd7b3724f</uuid></WsStem><WsStem><idIndex>28958</idIndex><extension>OCIO</extension><displayExtension>Office
 of the 
CIO</displayExtension><description></description><displayName>Test:Service Line 
Org Tree:MUSC University:INFORMATION TECHNOLOGY:Office of the 
CIO</displayName><name>Test:sa:UNIV:IT:OCIO</name><uuid>cd411e50fb664f16b8c781c915cc310f</uuid></WsStem></stemResults><resultMetadata><resultCode>SUCCESS</resultCode><resultMessage>Success
 for: clientVersion: 2.3.0, wsStemQueryFilter: 
WsStemQueryFilter[stemQueryFilterType=FIND_BY_STEM_NAME_APPROXIMATE,stemName=Test:sa:UNIV:IT],
 actAsSubject: WsSubjectLookup[subjectId=GrouperSystem][\n]"
[DEBUG] wire - << ", params: null[\n]"
[DEBUG] wire - << ", wsStemLookups: null</resultMessage><"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] wire - << "b6[\r][\n]"
[DEBUG] wire - << 
"success>T</success></resultMetadata><responseMetadata><resultWarnings></resultWarnings><millis>42</millis><serverVersion>2.3.0</serverVersion></responseMetadata></WsFindStemsResults>"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] wire - << "0[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] BasicClientConnectionManager - Releasing connection 
org.apache.http.impl.conn.ManagedClientConnectionImpl@3543df7d
[DEBUG] BasicClientConnectionManager - Connection can be kept alive for 5000 
MILLISECONDS
Success response: HTTP/1.1 200 OK
XML was 28841ITINFORMATION TECHNOLOGYTest:Service Line Org Tree:MUSC 
University:INFORMATION 
TECHNOLOGYTest:sa:UNIV:ITb1e93a1f819a4090b97679cbd7b3724f28958OCIOOffice of the 
CIOTest:Service Line Org Tree:MUSC University:INFORMATION TECHNOLOGY:Office of 
the CIOTest:sa:UNIV:IT:OCIOcd411e50fb664f16b8c781c915cc310fSUCCESSSuccess for: 
clientVersion: 2.3.0, wsStemQueryFilter: 
WsStemQueryFilter[stemQueryFilterType=FIND_BY_STEM_NAME_APPROXIMATE,stemName=Test:sa:UNIV:IT],
 actAsSubject: WsSubjectLookup[subjectId=GrouperSystem]
, params: null
, wsStemLookups: nullT422.3.0
WsFindStemsResults was

From: Suderman Keith [mailto:[email protected]]
Sent: Tuesday, June 07, 2016 2:42 PM
To: [email protected]
Subject: Re: HTTPBuilder and Content-type




On Jun 7, 2016, at 11:40 AM, Imholz, John J. 
<[email protected]<mailto:[email protected]>> wrote:

I'm still not sure how to get the Content-type sent as 'text/xml' (the 
webservice I'm hitting doesn't like 'application/xml’.)

You should just be able to specify the content type as ‘text/xml’ without 
having to use one of the ContentType enum values.  E.g.

http.request(POST, ‘text/xml’)

Cheers,
Keith


Can I get some insight on how to log http components when executing a groovy 
script from the command line?

jji

From: David Clark [mailto:[email protected]]
Sent: Tuesday, June 07, 2016 11:03 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: HTTPBuilder and Content-type

The content-type is set to the content type of the encoder. See here:

https://github.com/jgritman/httpbuilder/blob/master/src/main/java/groovyx/net/http/EncoderRegistry.java#L333

For the xml encoder that is "application/xml". See here (the first entry in the 
list is taken to be the default content-type):

https://github.com/jgritman/httpbuilder/blob/master/src/main/java/groovyx/net/http/ContentType.java#L67

Your best bet is to enable debugging in the apache http client to see what is 
actually being sent. You can do this by setting the system properties 
correctly. See here for the details on how to do this:

https://hc.apache.org/httpcomponents-client-ga/logging.html


On Tue, Jun 7, 2016 at 8:15 AM, Imholz, John J. 
<[email protected]<mailto:[email protected]>> wrote:
I'd like to set the Content-type of a POST to "text/xml"  looks to me like 
http.request( POST, XML)  sets it to "application/xml".

Also, to debug, how can I see the POST before I send it?

jji

------------------------------
Research Associate
Department of Computer Science
Vassar College
Poughkeepsie, NY

Reply via email to