Forum Discussion

sdeng's avatar
sdeng
New Contributor II
7 years ago
Solved

SOAP Customize Envelope

Do you have a sample for soap execute>customized envelope> foreach Function? What’s the language we should use in customized envelope?

  • You can use Apache velocity to do foreach, if and etc.

    Example:

    <SOAP-ENV:Envelope
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:ns1="urn:general_2015_2.transactions.webservices.netsuite.com"
        xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:ns0="urn:messages_2015_2.platform.webservices.netsuite.com"
        xmlns:ns3="urn:core_2015_2.platform.webservices.netsuite.com"
        xmlns:ns4="urn:core_2015_2.platform.webservices.netsuite.com">
        <SOAP-ENV:Header>
            <ns0:applicationInfo>
                <ns0:applicationId>$Soap_Execute_applicationId</ns0:applicationId>
            </ns0:applicationInfo>
            <ns0:passport>
                <ns4:email>$Soap_Execute_Passport_email</ns4:email>
                <ns4:password>$Soap_Execute_Passport_password</ns4:password>
                <ns4:account>$Soap_Execute_Passport_account</ns4:account>
            </ns0:passport>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns0:add>
                <ns0:record ns2:type="$record.journalEntry">
                    <ns1:customForm internalId="$record.customForm.internalId" />
                    <ns1:postingPeriod internalId="$record.postingPeriod.internalId"/>
                    <ns1:tranDate>$record.tranDate</ns1:tranDate>
                    <ns1:tranId>$record.tranId</ns1:tranId>
                    <ns1:createdFrom internalId="$record.createdFrom.internalId"/>
                    <ns1:subsidiary internalId="$record.subsidiary.internalId"/>
                    <ns1:reversalDate>$record.reversalDate</ns1:reversalDate>
                    <ns1:reversalDefer>$record.reversalDefer</ns1:reversalDefer>
                    <ns1:approved>$record.approved</ns1:approved>
                    <ns1:memo>$record.memo</ns1:memo>
                    <ns1:customFieldList>
                        <ns3:customField ns3:scriptId="$record.batchId.scriptId" ns3:internalId="$record.batchId.intId" ns2:type="$record.batchId.type">
                            <ns3:value>$record.custbody_batch_id</ns3:value>
                        </ns3:customField>
                        <ns3:customField ns3:scriptId="$record.customFieldList.customField[0].scriptId" ns:internalId="$record.customFieldList.customField[0].internalId" ns2:type="ns3:SelectCustomFieldRef">
                            <ns3:value>$record.customFieldList.customField[0].value.internalId</ns3:value>
                        </ns3:customField>
                    </ns1:customFieldList>
                    <ns1:lineList>
                    #set ($a = -1)
                    #foreach($line in $record.lineList.line)
                        <ns1:line>
                        #set ($a = $a+1)
                            <ns1:account internalId="#foreach($account in $record.lineList.line[$a].account)$account#end"></ns1:account>
                            <ns1:debit>$record.lineList.line[$a].debit</ns1:debit>
                            <ns1:credit>$record.lineList.line[$a].credit</ns1:credit>
                            <ns1:memo>$record.lineList.line[$a].memo</ns1:memo>
                            <ns1:custbody_custom_jnl_id>$record.lineList.line[$a].custbody_custom_jnl_id</ns1:custbody_custom_jnl_id>
                            <ns1:department externalId="#foreach($department in $record.lineList.line[$a].department)$department#end"/>
                            <ns1:class internalId="#foreach($class in $record.lineList.line[$a].class)$class#end"/>
                            <ns1:customFieldList>
                                <ns3:customField ns3:scriptId="$record.product.scriptId" ns3:internalId="$record.product.intId" ns2:type="$record.product.type">
                                    <ns3:value internalId="#foreach($value in $record.lineList.line[$a].customFieldList.customField[0].value)$value#end"></ns3:value>
                                </ns3:customField>
                            </ns1:customFieldList>
                        </ns1:line>#end 
                    </ns1:lineList>
                </ns0:record>
            </ns0:add>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

5 Replies

  • @robin Do you have any samples of Soap Execute we could share?

    The language used in the customized envelope is XML and will be based on the WSDL that is used with the Soap request.

    • sdeng's avatar
      sdeng
      New Contributor II

      Below is one generated template from workday webservice, can you explain how foreach work here? How will be the mapper before this soap execute if multi-workers for one Provisioning_Group?

      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/
      xmlns:ns0=“urn:com.workday/bsvc”>
      SOAP-ENV:Header
      ns0:Workday_Common_Header
      ns0:Include_Reference_Descriptors_In_Response$Include_Reference_Descriptors_In_Response</ns0:Include_Reference_Descriptors_In_Response>
      </ns0:Workday_Common_Header>
      </SOAP-ENV:Header>
      SOAP-ENV:Body
      <ns0:Put_Provisioning_Group_Assignment_Request ns0:version=“$version”>
      <ns0:Provisioning_Group_Assignment_Reference ns0:Descriptor=“$Provisioning_Group_Assignment_Reference.Descriptor”>#foreach($ID in $Provisioning_Group_Assignment_Reference.ID)
      <ns0:ID ns0:type=“$ID.type”>$ID.value</ns0:ID>#end
      </ns0:Provisioning_Group_Assignment_Reference>
      ns0:Provisioning_Group_Assignment_Data
      <ns0:Worker_Reference ns0:Descriptor=“$Provisioning_Group_Assignment_Data.Worker_Reference.Descriptor”>#foreach($ID in $Provisioning_Group_Assignment_Data.Worker_Reference.ID)
      <ns0:ID ns0:type=“$ID.type”>$ID.value</ns0:ID>#end
      </ns0:Worker_Reference>
      ns0:Provisioning_Group$Provisioning_Group_Assignment_Data.Provisioning_Group</ns0:Provisioning_Group>
      ns0:Status$Provisioning_Group_Assignment_Data.Status</ns0:Status>
      ns0:Last_Changed$Provisioning_Group_Assignment_Data.Last_Changed</ns0:Last_Changed>
      </ns0:Provisioning_Group_Assignment_Data>
      </ns0:Put_Provisioning_Group_Assignment_Request>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      • stodoroska's avatar
        stodoroska
        New Contributor III

        You can use Apache velocity to do foreach, if and etc.

        Example:

        <SOAP-ENV:Envelope
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:ns1="urn:general_2015_2.transactions.webservices.netsuite.com"
            xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:ns0="urn:messages_2015_2.platform.webservices.netsuite.com"
            xmlns:ns3="urn:core_2015_2.platform.webservices.netsuite.com"
            xmlns:ns4="urn:core_2015_2.platform.webservices.netsuite.com">
            <SOAP-ENV:Header>
                <ns0:applicationInfo>
                    <ns0:applicationId>$Soap_Execute_applicationId</ns0:applicationId>
                </ns0:applicationInfo>
                <ns0:passport>
                    <ns4:email>$Soap_Execute_Passport_email</ns4:email>
                    <ns4:password>$Soap_Execute_Passport_password</ns4:password>
                    <ns4:account>$Soap_Execute_Passport_account</ns4:account>
                </ns0:passport>
            </SOAP-ENV:Header>
            <SOAP-ENV:Body>
                <ns0:add>
                    <ns0:record ns2:type="$record.journalEntry">
                        <ns1:customForm internalId="$record.customForm.internalId" />
                        <ns1:postingPeriod internalId="$record.postingPeriod.internalId"/>
                        <ns1:tranDate>$record.tranDate</ns1:tranDate>
                        <ns1:tranId>$record.tranId</ns1:tranId>
                        <ns1:createdFrom internalId="$record.createdFrom.internalId"/>
                        <ns1:subsidiary internalId="$record.subsidiary.internalId"/>
                        <ns1:reversalDate>$record.reversalDate</ns1:reversalDate>
                        <ns1:reversalDefer>$record.reversalDefer</ns1:reversalDefer>
                        <ns1:approved>$record.approved</ns1:approved>
                        <ns1:memo>$record.memo</ns1:memo>
                        <ns1:customFieldList>
                            <ns3:customField ns3:scriptId="$record.batchId.scriptId" ns3:internalId="$record.batchId.intId" ns2:type="$record.batchId.type">
                                <ns3:value>$record.custbody_batch_id</ns3:value>
                            </ns3:customField>
                            <ns3:customField ns3:scriptId="$record.customFieldList.customField[0].scriptId" ns:internalId="$record.customFieldList.customField[0].internalId" ns2:type="ns3:SelectCustomFieldRef">
                                <ns3:value>$record.customFieldList.customField[0].value.internalId</ns3:value>
                            </ns3:customField>
                        </ns1:customFieldList>
                        <ns1:lineList>
                        #set ($a = -1)
                        #foreach($line in $record.lineList.line)
                            <ns1:line>
                            #set ($a = $a+1)
                                <ns1:account internalId="#foreach($account in $record.lineList.line[$a].account)$account#end"></ns1:account>
                                <ns1:debit>$record.lineList.line[$a].debit</ns1:debit>
                                <ns1:credit>$record.lineList.line[$a].credit</ns1:credit>
                                <ns1:memo>$record.lineList.line[$a].memo</ns1:memo>
                                <ns1:custbody_custom_jnl_id>$record.lineList.line[$a].custbody_custom_jnl_id</ns1:custbody_custom_jnl_id>
                                <ns1:department externalId="#foreach($department in $record.lineList.line[$a].department)$department#end"/>
                                <ns1:class internalId="#foreach($class in $record.lineList.line[$a].class)$class#end"/>
                                <ns1:customFieldList>
                                    <ns3:customField ns3:scriptId="$record.product.scriptId" ns3:internalId="$record.product.intId" ns2:type="$record.product.type">
                                        <ns3:value internalId="#foreach($value in $record.lineList.line[$a].customFieldList.customField[0].value)$value#end"></ns3:value>
                                    </ns3:customField>
                                </ns1:customFieldList>
                            </ns1:line>#end 
                        </ns1:lineList>
                    </ns0:record>
                </ns0:add>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>