Forum Discussion

acesario's avatar
acesario
Contributor II
5 years ago
Solved

Questions a soap execute Template

I’m struggling with what the soap execute is doing based on the contents of the generated soap template and apache velocity statements therein. Apologies in advance for any dumb questions, still new to this and my first crack at the apache veloicty statements.

Some of this may be rubber ducking, but I’ll post any answers I find. Here goes:

  1. My understanding is that the mapper values push to the template, which works with the snap to generate the soap payload for the designated web service. How does the template generate values exactly? And is there a way that I can see the exact payload in xml (not in json)?

Q2. Answered/ Can I hard code values? (or do I need to do all that in the mapper) For example, the type and value here:
<ns0:ID ns0:type=“Student_Course_Section_ID”>COURSE_SECTION_AAS202-01201201</ns0:ID> ANSWER: YES

  1. Is there a debugger of any kind for the soap generation or apache velocity statements being used?

Q4. Answered Could I just write out a complete xml with all data elements and put it in the template, submit the soap and have it work with no mapper? ANSWER: YES, I tested this and was able to hardcode all values and submit without an issue for a simple get web service.

Q5. Can I use a new created variable from the mapper, instead of what comes in from the schema. For example $MyVar instead of the mapped ANSWER: YES

  • @acesario, take a look at the XML Generator snap. Paste your XML + Velocity in its Edit XML template, create an input view, and feed your Mapper into the XML Generator. It will output your XML as a string value to the $xml key.

11 Replies

  • del's avatar
    del
    Contributor III

    @acesario, take a look at the XML Generator snap. Paste your XML + Velocity in its Edit XML template, create an input view, and feed your Mapper into the XML Generator. It will output your XML as a string value to the $xml key.

    • tk421_cogenics's avatar
      tk421_cogenics
      New Contributor II

      This is a good descriptio of the XML Generator usage.

      I have found it good practice when working with SOAP Services that once you have the Request Template generated, copy the template over to an XML Generator Snap. This helps with building the request before making repeated failed calls to the service and helps with triage of failed requests and/or errors that may pop-up after deployment.

  • acesario's avatar
    acesario
    Contributor II

    I got a working, hardcode example with a foreach working.

    Here is an example, with my custom variables in a mapper.

    …and a section of my template for this:

    Blockquote #foreach($ID in $FORMAT.ID)
    ns0:Course_Section_Combination_Instructional_Format_Contact_Hours_Data
    ns0:Section_Combination_Instructional_Format_Reference
    <ns0:ID ns0:type=“Instructional_Format_ID”>$ID</ns0:ID>
    </ns0:Section_Combination_Instructional_Format_Reference> ns0:Course_Section_Instructional_Format_Contact_Hours0</ns0:Course_Section_Instructional_Format_Contact_Hours>
    </ns0:Course_Section_Combination_Instructional_Format_Contact_Hours_Data>
    #end

    Now onto the real, mapped values.

  • acesario's avatar
    acesario
    Contributor II
    1. Are there other places in snaplogic where we can use the apache velocity processing?
  • acesario's avatar
    acesario
    Contributor II

    @del, thanks for the reply and good idea! I wouldn’t have thought to use the xml generator like that. Very good sir!

  • acesario's avatar
    acesario
    Contributor II

    @tk421_cogenics , are you required to add a schema to the xml generator? or just the template?

    • acesario's avatar
      acesario
      Contributor II

      Here is an error I get from the xml generator:
      error":“An error occurred while parsing the request document”

      “stacktrace”:
      "com.snaplogic.api.ExecutionException: An error occurred while parsing the request document\n\tat com.snaplogic.snap.api.xml.XmlUtilsImpl.stripNodeAndAttributeNodesWithNullablesOld(XmlUtilsImpl.java:577)\n\tat com.snaplogic.snap.api.xml.XmlUtilsImpl.stripNodeAndAttributeNodes(XmlUtilsImpl.java:489)\n\tat com.snaplogic.snaps.tra
      lineNumber: 8; columnNumber: 310; The reference to entity “term_id-1” must end with the ‘;’
      “reason”:

      “The reference to entity “term_id-1” must end with the ‘;’ delimiter.”

      “resolution”:

      “Please verify the validity of the XML document”

      "

      • acesario's avatar
        acesario
        Contributor II

        Oh, ther is an & after term id. No worries.

  • acesario's avatar
    acesario
    Contributor II

    How does snap handle the namespaces?
    My xml has ?xml version=“1.0” encoding=“UTF-8”?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/
    xmlns:ns0=“urn:com.workday/bsvc”>

    Woud the namespaces need to be configured like this?

  • acesario's avatar
    acesario
    Contributor II

    I have this working now. The xml generator is SUPER helpful

    example:

    Copy the customized envelope from your soap execute:

    and paste it into the ‘Edit XML’ within the generator snap

    The resulting document will have your output in the $xml as shown: