parse web service response

E

eunever32

Hi

I am calling a web service directly via http because I'm using the
proxy gateway.

So instead of Object object = call.invoke(soapEnvelope)

I'm doing

HttpClient client
client.executeMethod(postMethod)
....
And then read the response into a string.

My question is:
When I examine the response I see:
------=_Part_7_21866603.1269262621509
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <7CDE7D3D9A8ECEA3A8DDC9F2E22917BB>

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://
....
</soapenv:Envelope>
------=_Part_7_21866603.1269262621509
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id: <masterLayout>

%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
%%EOF

------=_Part_7_21866603.1269262621509--

Is there some API that I can use to cast the above into an object and
then obtain the soap response and attachment?

Thanks
 
R

RedGrittyBrick

Hi

I am calling a web service directly via http because I'm using the
proxy gateway.

So instead of Object object = call.invoke(soapEnvelope)

I'm doing

HttpClient client
client.executeMethod(postMethod)
...
And then read the response into a string.

My question is:
When I examine the response I see:
------=_Part_7_21866603.1269262621509
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id:<7CDE7D3D9A8ECEA3A8DDC9F2E22917BB>

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://
...
</soapenv:Envelope>
------=_Part_7_21866603.1269262621509
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id:<masterLayout>

%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
%%EOF

------=_Part_7_21866603.1269262621509--

Is there some API that I can use to cast the above into an object and
then obtain the soap response and attachment?

As I see it you have two options:

1) Use a SOAP API for SOAP if you want SOAP-like processing of SOAP
objects. Search an archive of this newsgroup for recommendations. It
probably wouldn't hurt to try whatever SOAP API seems to be foremost in
your IDE. I'd be surprised if any SOAP API couldn't cope with a regular
HTTP-proxy (or a Socks proxy)

2) Use HttpClient if you are happy to parse the returned XML using an
XML parsing API - I'd use a DOM (not SAX) style API to parse the XML and
XPath to extract values but YMMV. Then construct your own objects from
the extracted set of values.

Approach 1 is the obvious one and I expect most people find it to be
easier (assuming you have WSDL, XSD etc).

Which SOAP (web-services) API had you tried and found to lack proxy support?
 
T

Tom Anderson

I am calling a web service directly via http because I'm using the proxy
gateway.

A reputable SOAP library will handle proxies. You don't have to do it
yourself.

Can you use Metro, aka the JAX-WS reference implementation, which comes as
part of the JDK for 1.6 onwards and is a separate download for 1.4 and
1.5? If you're starting from WSDL, you can; not sure whether you can if
you're not. Metro uses java's standard HttpConnection for its connections,
and that can use proxies; you configure this using system properties, or
some other mechanisms:

http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html

tom
 
A

Arne Vajhøj

I am calling a web service directly via http because I'm using the
proxy gateway.

I would be very surprised if your web service toolkit does
not support proxies.
My question is:
When I examine the response I see:
------=_Part_7_21866603.1269262621509
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id:<7CDE7D3D9A8ECEA3A8DDC9F2E22917BB>

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://
...
</soapenv:Envelope>
------=_Part_7_21866603.1269262621509
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id:<masterLayout>

%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
%%EOF

------=_Part_7_21866603.1269262621509--

Is there some API that I can use to cast the above into an object and
then obtain the soap response and attachment?

I really believe that you should use a web service toolkit to make
the call.

But even if not then I would expect a web service toolkit to
have some parsing classes that you can reuse in your code for
the SOAP part.

Only as last resort go to pure W3C DOM.

The attachment is easy. That is just taking everything between the
two blank lines and stuff it in a file.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top