Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate SOAP message example #14

Open
briandignan opened this issue Jul 24, 2013 · 8 comments
Open

Generate SOAP message example #14

briandignan opened this issue Jul 24, 2013 · 8 comments

Comments

@briandignan
Copy link

If you have time, would you be able to add a little more explanation to the "Generate and post a SOAP message" portion of the manual? Here's the request that I generated from the example code:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>KHR</web:FromCurrency>
         <web:ToCurrency>MDL</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>
</code>

I have almost no experience with SOAP, so maybe this is obvious, but in this situation how do you specify the FromCurrency and ToCurrency values? It seems like KHR and MDL are picked every time, but I couldn't figure out why or how to change them.

Also, when running the example against http://www.webserviceX.NET/ConversionRate, TransmissionException was being thrown with a message "HTTP response=[Internal Server Error] code=[500]". Maybe there's something wrong with their site?

@tombujok
Copy link
Member

Please, have a look at the examples:
https://github.com/reficio/soap-ws/tree/master/soap-examples

Especially at this one:
https://github.com/reficio/soap-ws/blob/master/soap-examples/quickstart/src/test/groovy/org/reficio/ws/quickstart/QuickStart.groovy

In order to tweak the message I use Groovy and XmlSlurper. In Java you would have to use XSLT or sth similar.

@ghost
Copy link

ghost commented Aug 1, 2013

Actually, the examples in Java aren't really useful, because they don't show how to set the parameters of the various calls. I'm tempted to go direct and just post XML, but I'd rather use the builder if possible. Are you saying that in the end we have to manipulate the XML in the message directly, before posting the request?

@tombujok
Copy link
Member

tombujok commented Aug 5, 2013

Yep, that's the case. You have to handle the string - thus I use XmlSlurper.

Tom

Tom Bujok
Reficio™ - Reestablish your software!
http://www.reficio.org

On Thursday, August 1, 2013 at 11:21 PM, mannyveloso wrote:

Actually, the examples in Java aren't really useful, because they don't show how to set the parameters of the various calls. I'm tempted to go direct and just post XML, but I'd rather use the builder if possible. Are you saying that in the end we have to manipulate the XML in the message directly, before posting the request?


Reply to this email directly or view it on GitHub (#14 (comment)).

@pwilla
Copy link

pwilla commented Sep 16, 2013

Sorry to ressurrect this, but I am also trying to get the example to work, and it generates the XML nicely, but I get the same 500 Internal Server Error. If I copy and paste the XML in SoapUI it gets a valid response.

@tombujok tombujok reopened this Sep 16, 2013
@pwilla
Copy link

pwilla commented Sep 16, 2013

Just tested with the same service (CurrencyConverter), with the Soap12 binding and it worked from the project. Still doesn't work on Soap(11?) binding though.

@chryschabs
Copy link

Hi there, this project is really great, been using it for a little while especially for the SoapBuilder. I've got around modifying the contents of the XML using another library I favor for XML manipualtion (jdom). Small question/favor. Would it be possible to include the error message/failure reason when throwing back a TransmissionException (internal error 500) ? The additional details would prevent me from having to parse my log files for the actual cause of the error message. Thank you.

@tmarly
Copy link

tmarly commented May 2, 2015

(this issue is also related to issue #24)

In order to avoid XML manipulations (with java it's rather a pain in the a..) to change the message, a good solution would be to have tokens in the message (":var1:", ...) instead of fake content (or '?'), that we could replace later with a simple string seach / replace ...

I see that SoapContext has methods to change the content of the input parameters (SoapContext.exampleContent(boolean)), so that would be a good entry point.

@cfalzone
Copy link

+1 Having the ability to set the parameters in the request builder would be great.

I did for now something like:

            String request = builder.buildInputMessage(operation);

            Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
                new InputSource(new ByteArrayInputStream(request.getBytes("utf-8"))));
            XPath xpath = XPathFactory.newInstance().newXPath();
            NodeList nodes = (NodeList)xpath.evaluate(
                "//Body/getAllPostedJobs/modifiedSinceDate", doc, XPathConstants.NODESET);
            for (int idx = 0; idx < nodes.getLength(); idx++) {
                nodes.item(idx).setTextContent(modifiedSinceDate.toString());
            }
            Transformer xformer = TransformerFactory.newInstance().newTransformer();
            StringWriter writer = new StringWriter();
            xformer.transform(new DOMSource(doc), new StreamResult(writer));
            request = writer.getBuffer().toString();

A lot to do to set one property on the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants