I am new to webservices. I've tried how to invoke external webservices which uses HTTP GET binding (passing in parameter using URL). My question is how to invoke external webservices which uses SOAP1/2 binding? My intention is to pass file over internet by encoding the file into byte array and take it as one of parameters. On the other side, the webservices provider will decode the byte array string back to file. Because the file size will be around 10k, I can only use SOAP binding, am I right about this? If so, how to invoke this webservice in the java client side? Any advice or link will be appreciated.
Originally posted by wil loo: I've tried how to invoke external webservices which uses HTTP GET binding (passing in parameter using URL). My question is how to invoke external webservices which uses SOAP1/2 binding?
SOAP web services always use HTTP POST - that is the only way you can pass the SOAP request envelope to the web server. It would be possible to send a SOAP response as a result of a HTTP GET request - however that combination is highly unlikely as the request would not be able to use SOAP's extension features.
Originally posted by wil loo: Because the file size will be around 10k, I can only use SOAP binding, am I right about this?
File transfer is not limited to SOAP. Does this "web service provider" already exist?. Because right now it doesn't even seem like the style (SOAP, RESTful, XML-over-HTTP, etc.) of web service has been selected yet.
Even if you have to use SOAP there are a a variety of protocols for "file attachments" like DIME (never standardized and not well supported under Java), SOAP with Attachments (SwA, fairly well supported under Java SOAP stacks but not necessarily on SOAP stacks for other implementation platforms), or theSOAP Message Transmission Optimization Mechanism (MTOM, the most recent protocol only supported by fairly recent SOAP stacks). Not every SOAP stack supports all these protocols and each protocol may have a different API for each SOAP stack implementation. Of course you could also simply transfer the file as base64 encoded data (see: Send binary data without using attachments).
A RESTful web service would probably expose a URL for a "parent resource" that accepts your (possibly binary) file through an HTTP-POST. That parent resource would then create a new "child resource" from your file and return a URL that makes your new resource identifiable (a URL is a URI) and addressable (as the URI also happens to be a URL). You can then use that new URI to refer to your file in any future interactions with the web service.
An XML-over-HTTP web service would probably accept the file as an XML document through an HTTP-POST; the document would specify meta data like the filename and would also contain the base64 encoded content of the file.
Hi Peer Reynders, thanks for your all-sided info. Like you can tell and I can guess, there are many ways to do the task (sending file via ws) and I don't have strong sense for which option will suit my situation (have done some research but still ... ws is fair big topic). So to aim the task I got, here is the story.
In the application user sometimes would like to send a fax, which takes a pdf file as attachment, and the fax server locates on a different box from the app server. So there will be a webservices on the fax server to take fax_no etc and the pdf attachment as parameters. The App will generate the pdf file and transform it to base64 encoded data and then invoke the ws when triggered by users. This is the current solution, and business client has provided the wsdl, they have done the ws provider part using .NET (vb), and I will implement ws client side using java.
The pdf file will be around 10kb, and we don't want the app's performance heavily affected by this action (the overhead caused by file transform, webservices, etc.). Because as you know I don't have much exp on webservice, I cannot see the full picture of what would be the best solution to this. Could you advise the best solution we can have nowadays, so that I can suggest business client? BTW: the java version 1.3, j2ee 1.2, Websphere App Server 5.1
Thank you very much for your help!
subject: How to use java to invoke an external webservices (soap, soap1.2)?