Am I just stupid, or is this really supposed to be difficult?
posted 9 years ago
I got tasked with a seemingly simple task. The client needs to be able to submit a simple XML doc (from a .NET or Java client) to a web service. I figure, ok, this should be easy since just playing around my little Hello World app done with axis2 worked out fine (a bit awkward on the client stub side but I figured it out). Now, however, I'm running into issues trying to get an XML string to post to the web service. (posted here here earlier about it.)
Been googling and trying different things. Apparently, if what I've researched is correct, I'll need to accept something like a byte on the web service side or else post to the service as an attachment with MTOM or SwA. Looking at the MTOM and SwA examples, this approach seemed like a ton of work. (It didn't look like the easy approach of simply adding a services.xml file describing my POJO would work that nicely. The client side looked pretty bad too.) So I figured it should be easy enough to just use a byte array on the service side method (instead of a String), but then my axis2 generated client stubs seems to want to use DataHandler (not take a byte directly) but I can't figure out what in the world I'm supposed to do with it to get my byte array into it.
I can't be the first person trying to send XML to a web service, so I just be missing something simple. (I still don't get what's going on that just doing escaping of the characters doesn't help xmlSpec = xmlSpec.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">"); It's as if, even escaped, the soap body must get messed up.)
Any pointers on what I need to do get a simple XML doc sent to a webservice? I feel like an idiot that it's taken me this long and don't have a solution.