[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Encoding SOAP XML string



All:

      We are using XML to pass a SOAP envelope to our webservice.  We are
having problems with special characters within the string that is built.
Is there something built into HTTPAPI that I could use to encode the whole
XML string before sending it to the webservice?  Any examples that you have
would be appreciated.

Thanks in advance for your help.
Michelle Himebaugh
Systems Analyst
Dart Container Corporation


Here is our code:

H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI':'QC2LE')
 * Access file where UserID and Password is stored for this job
FFTMCL02   IF   E           K DISK
 **************************************************************************
 * DATA STRUCTURE DEFINITIONS
 **************************************************************************
D                SDS
D #PGM                    1     10
 **************************************************************************
 * WORK FIELD DEFINITION
 **************************************************************************
 /copy httpapi_h
D SOAP            s          32767A   varying
D rc              s             10I 0
D ENVIRONMNT      S              4    DTAARA(ENVIRONMNT)
D Domain          S             35
D NameSpace       S             35
D UserID          S             30
D PassWord        S             30
 **************************************************************************
 * KEY FIELD DEFINITIONS
 **************************************************************************
D $MCJOB          S                   LIKE(MCJOB)
 **************************************************************************
 * PROTOTYPE DEFINITION
 **************************************************************************
D Add_SOAPACTION  PR
D   Header                    1024A   varying
D   UserData                      *   value
D MSRS001         PR
D  SentName                   1000A   varying
D  Sentfrom                   1000A   varying
D  SendTo                     1000A   varying
D  SendCC                     1000A   varying
D  SendBcc                    1000A   varying
D  Subject                    1000A   varying
D  Body                      10000A   varying
D  BodyIsHTML                    1A   varying
 **************************************************************************
 * PROCEDURE INTERFACE
 **************************************************************************
D MSRS001         PI
D  @SentName                  1000A   varying
D  @SentFrom                  1000A   varying
D  @SendTo                    1000A   varying
D  @SendCC                    1000A   varying
D  @SendBcc                   1000A   varying
D  @Subject                   1000A   varying
D  @Body                     10000A   varying
D  @BodyIsHTML                   1A   varying
 **************************************************************************
 * MAINLINE - MAINLINE - MAINLINE - MAINLINE - MAINLINE - MAINLINE
 **************************************************************************
C                   IN        ENVIRONMNT
 /free
    $MCJOB = #PGM;
    Chain $MCJOB FTMCL02;
    UserID = MCUSER;
    PassWord = MCPWD;

    NameSpace = 'dartcontainer.com';
     If ENVIRONMNT = 'TEST';
        Domain = 'intranet.test.dartcontainer.com';
     Else;
        Domain = 'intranet.dartcontainer.com';
     Endif;
    // Build SOAP call
    SOAP =
     '<?xml version="1.0" encoding="US-ASCII" ?> '
    + '<soap:Envelope '
    +   'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; '
    +   'xmlns:xsd="http://www.w3.org/2001/XMLSchema"; '
    +   'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";> '
    +   '<soap:Body> '
    +    '<SendSMTPMail '
    +     'xmlns="http://'+%Trim(NameSpace)+'/SendMailServer/SMTPMail"> '
    +     '<sentFrom>'     + %trim(@SentName)   + '</sentFrom> '
    +     '<replyTo>'      + %trim(@SentFrom)   + '</replyTo> '
    +     '<sendToString>' + %trim(@SendTo)     + '</sendToString> '
    +     '<sendCCString>' + %trim(@SendCC)     + '</sendCCString> '
    +     '<sendBCCString>'+ %trim(@SendBCC)    + '</sendBCCString> '
    +     '<subject>'      + %trim(@Subject)    + '</subject> '
    +     '<body><![CDATA['+ %trim(@Body)       + ']]></body> '
    +     '<bodyIsHTML>'   + %trim(@BodyIsHtml) + '</bodyIsHTML> '
    +     '<template>'     + ' '                + '</template> '
    +    '</SendSMTPMail> '
    +   '</soap:Body> '
    + '</soap:Envelope>';
  http_debug(*ON);
  // http_xmlns(*ON);
  // This tells HTTPAPI to call our subprocedure when assembling the
  // HTTP headers to send to the remote server.
  http_xproc(HTTP_POINT_ADDL_HEADER :%paddr(Add_SOAPACTION));
  // Setup User ID and password
  callp http_setauth(HTTP_AUTH_BASIC:UserID:PassWord);
  rc = http_url_post_xml(
       'https://'+%Trim(Domain)+'/SendMailServer/SMTPMail.asmx'
       :%addr(SOAP) + 2 :%len(SOAP) :*NULL :*NULL :*NULL
       :HTTP_TIMEOUT :HTTP_USERAGENT :'text/xml');

  if (rc <> 1);
     http_crash();
  endif;

  *inlr = *on;

 /end-free
 **************************************************************************
 * Add_SoapAction - Internal Procedure
 *
 * HTTPAPI will call this just before sending the HTTP headers
 * to the remote server.
 *
 * This procedure lets us add any header we like to the
 * HTTP request.
  *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 P Add_SOAPACTION  B
 D Add_SOAPACTION  PI
 D   Header                    1024A   varying
 D   UserData                      *   value
  /free
     Header = 'SOAPAction: '
            + 'http://'+%Trim(NameSpace)+'/SendMailServer'
            + '/SMTPMail/SendSMTPMail'
            + x'0d25';
  /end-free
 P                 E

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------