• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Request using HttpClient

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I am trying to communicate with another application from our application based on XML request and response scenario.

Initially, I sent a XML request using HttpConnection (open connection, write a stream and flush it) and go successfull response back.. But when I tried to send the same request using HttpClient ( post method) am getting XML Malformed error message. I am guessing, will HttpClient (common's) implementation may add some kind of HTTP enevlope the XML request.
1. Is my guess correct?
2. Please explain what is happening there?? (it is working with HttpConnection but not with HttpClient)

Thanks,
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no such thing as an HTTP envelope, just an HTTP header (which may differ slightly between HTTP libraries). But that should have no impact on the HTTP body.

Is the request being received by the other side the same in both cases? It sounds like it is not, and investigating how it differs would be an important first step in tracking this down. You could write the full request stream to a file in both cases and compare them.
 
Yellapa Adepu
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Incase of HttpClient, it is adding some escape characters in the request. That is causing the problem. Please help how to avoid this.. here is the request info..

with HttpConnection:
<?xml version="1.0" encoding="UTF-8"?> <binderRequest> <source>MyApp</source> <requestID>5555555551177436669446</requestID> <agencyAgent>5442-015</agencyAgent> <demographic> <ssn>555555555</ssn> <dob>1972-05-04</dob> <firstName>aa</firstName> <lastName>bb</lastName> <address1>asdf</address1> <address2>sdf</address2> <city>sdf</city>
</demographic> </binderRequest>.

with HttpClient:
SWEExtData=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3CbinderRequest
%3E%3Csource%3EISS%3C%2Fsource%3E%3CrequestID%3E5555555551177436670087%3C%2FrequestID%3E%3C
agencyAgent%3E5442-015%3C%2FagencyAgent%3E%3Cdemographic%3E%3Cssn%3E555555555%3C%2Fssn%3E%3C
dob%3E1972-05-04%3C%2Fdob%3E%3CfirstName%3Eaa%3C%2FfirstName%3E%3ClastName%3Ebb%3C%2FlastName%3E%3C
address1%3Easdf%3C%2Faddress1%3E%3Caddress2%3Esdf%3C%2Faddress2%3E%3Ccity%3Esdf%3C
%2Fcity%3E%2Fdemographic%3E%2FbinderRequest%3E&S WEExtSource=ProcessCBPPPayment&SWEExtCmd=Execute

It is adding %3E (something) in place of < and >

Thanks,
[ April 24, 2007: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like URL-encoding is applied to the HTTP body, which doesn't make sense. How are you using HttpClient? Can you show us the pertinent code section?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic