Java Soap

Version 1
    This document was generated from CDN thread

    Created by: Andy Wallace on 26-09-2011 05:12:53 AM
    HI i have written a jar file that returns some data to me. For testing i have been calling the java code via expresion editor, this  then uses a web service by using a set command with the following in {  renewbuspass soapy  = new renewbuspass("1234567"); String xml = soapy.getRequest();  return xml; }
    However i have no idea how to change the above code to send a variable rather than the hard coded number 1234567. Any one out there help me?

    Subject: RE: Java Soap
    Replied by: Steven Pawlak on 26-09-2011 09:03:24 AM

    Any variable you declare in the IVR script can be simply referenced in the Expression Editor code. No need for declaration or instantiation.

    Also, I assume that you are using the Set step with a Document variable to hold the XML once it is returned.


    Subject: RE: Java Soap
    Replied by: Andy Wallace on 26-09-2011 10:14:15 AM
    HI Steve, yes it is a SET i am using. i seem to be hitting a problem escaping " .
    My Set command needs to reference a variable called Caller_number. THis is just a sting that contains a 7 digit number.
    So what i need to send is {  renewbuspass soapy  = new renewbuspass("2456879"); String xml = soapy.getRequest();  return xml; }
    In order to do this i am trying to use a variable where the number 2456879 is.
    "{  renewbuspass soapy  = new renewbuspass" + u"\""+Caller_Number+'\u0022'+"; String xml = soapy.getRequest();  return xml; }"
    However no matter what i try it always converts the above to include the \ in fromt of the "   So it does read the value but i end up with ("my number\") ather than (my number")   or do i have the syntax completly wrong for escaping the "
    i am at a real loss, i am starting to wonder if this is a bug.


    Subject: RE: Java Soap
    Replied by: Steven Pawlak on 26-09-2011 10:33:28 AM

    You do not need to escape anything.

    So Caller_Number is your IVR variable that gets populated by Steps before the Set Step.

    This is then your Set Step

    Variable = docVariable
    Value = {

         renewbuspass soapy  = new renewbuspass(Caller_Number);
         String xml = soapy.getRequest();

         return xml;

    Now docVariable has all the xml and you can use standard GetXML Document Data steps to parse it.

    Of course, you will want to put all of that in try catch finally and handle things properly.

    FYI - You can do a LOT of Java inside the { }. It is very powerful. You might be able to move the JAR in there too. I wrote a SOAP call inside a Set step. I pass a XML template after a Transform step in and get an XML doc out. Using various variable from the script directly in the Java. I made the whole thing a sub script and kept it generic enough that I can use it at any site.

    Hope this helps


    Subject: RE: Java Soap
    Replied by: Andy Wallace on 27-09-2011 02:45:39 AM
    Thanks¿ Steve, all sorted. The code you gave me was basically what i had at the beginning of the day. Unfortunately at that point i was using the wrong variable. This let me off at a complete tangent. Thanks for your help.