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

RE: ProcessXMLStringToDB



Ernie,

You didn't send the soap message. Your XML looks like it might work, but you have to format a SOAP message. Look at this page from the server you are using:

http://71.126.154.120/service.asmx?op=ProcessXMLStringToDB

Follow through the debug listing and try to match up what is shown. Be sure to follow either SOAP 1.1, SOAP 1.2 or the GET or the POST as you wish. Just make sure you are using the appropriate section with the parameters and type of request you are sending.

The example for SOAP 1.1 shows a SOAPAction: being sent...I don't see one in your debug file.
For SOAP 1.2, the Content-Type needs to change. The XML shown in the two SOAP examples is a soap message but your file only has XML in it. 
I would advise against the GET as it looks like your URL might get pretty long and it is just not good practice. Some servers/proxies/clients didn't like long GETs and so easiest just to ignore them.
The POST looks like something you tried before. You might have been close and by wrapping the <string> around your xml you might have it.

And we know the error message you are currently getting by reading the return file and seeing "<faultstring>", "Possible SOAP version mismatch: Envelope namespace  was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/."; That "namespace  " is because you didn't include a namespace (xmlns:).

This is where soapUI or similar tool can help (your WSDL is at http://71.126.154.120/service.asmx?WSDL ) . If you compare what soapUI says it should look like to the soap request shown in the URL above, they line up pretty well. 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:tem="http://tempuri.org/";>
   <soapenv:Header/>
   <soapenv:Body>
      <tem:ProcessXMLStringToDB>
         <!--Optional:-->
         <tem:Doc>?</tem:Doc>
      </tem:ProcessXMLStringToDB>
   </soapenv:Body>
</soapenv:Envelope>


The <tem:Doc>?</tem:Doc> is where your information goes. Someone correct me if I'm wrong but the elements of the Body do not have to be namespace-qualified. So you can just insert your XML there. Try using the SOAPAction and the soapenv: stuff and see how it works.



-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ernie Woods
Sent: Thursday, October 27, 2011 3:35 PM
To: HTTPAPI and FTPAPI Projects
Cc: 'Ken Fischer'; Keshav Rao
Subject: RE: ProcessXMLStringToDB

Hi Scott,
Thank you for your assistance. I set the content-type to text/xml and ran through the program.  The log and results are attached to this email.  The program does not fail, however the service program does not process the XML, or shall I say the expected results to update/add records to a sequel file do not occur.
Here is a copy of the program:
--------------------------------------------------------------------------------------------
H BNDDIR('HTTPAPI')

 **
 **    CRTBNDRPG CUSTPRODHR SRCFILE(libhttp/QRPGLESRC) DBGVIEW(*LIST) +
 **       DFTACTGRP(*NO) ACTGRP(*NEW)

D/copy qrpglesrc,httpapi_h
D/copy qrpglesrc,ifsio_h
D/copy qrpglesrc,errno_h

D cmd             pr                  extpgm('QCMDEXC')
D  command                     200A   const
D  length                       15P 5 const

D ContentType     s             64A
D rc              s             10I 0
D msg             s             52A
D stmf            S            256A

C     *entry        plist
C                   parm                    p_inpcust         4

 /free
  http_debug(*on);
  *inlr = *on;

  //** whatever data is in this stream file will
  //** be POSTed to the URL below.
  stmf = '/cgiforman/xmlexport/custprod'+p_inpcust+'.xml';

  //ContentType='application/x-www-form-urlencoded';

  ContentType='text/xml';

  rc=http_url_post_stmf('http://71.126.154.120'
    +'/service.asmx?op=ProcessXMLStringToDB'
    : %trimr(stmf)
    : '/tmp/http_result.txt'
    : HTTP_TIMEOUT
    : HTTP_USERAGENT
    : ContentType );

  if rc <> 1;
     msg = http_error();
     dsply msg;
     return;
  endif;

  //unlink('/tmp/http_result.txt');
  return;
---------------------------------------------------------------------------------------

I appreciate your help once again.
Ernie Woods
Sr. Programmer/Analyst


-----Original Message-----
From: Scott Klement [mailto:sk@xxxxxxxxxxxxxxxx]
Sent: Wednesday, September 14, 2011 4:58 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: ProcessXMLStringToDB

Hi Ernie,

This looks like the output of some program that interpreted a WSDL file?
  Am I reading it right?

Can you send the actual WSDL file?

Can you also send the document that you are sending, so I can compare it
to the WSDL file?  (Or, better, send an HTTPAPI debug log.)

Also, I'm a bit confused as to why you have the content-type set to a
URL-encoded web form.  Aren't you sending an XML document??



On 9/14/2011 1:06 PM, Ernie Woods wrote:
>
>     Scott,
>
>     I have included the RPG code I am using to post XML data from our
>     iSeries to a HTTP server.  The HTTP server is running a service
>     ProcessXMLStringToDB, I have included the service below.
>
>     When I run the RPG program it appears to work fine (no errors),
>     however the data is not updated on the ProcessXMLStringToDB service.
>
>     I am new at this and would like to know if I am doing something
>     wrong.  Possibly utilizing the wrong methods or parameters?
>
>     Any help would be appreciated.
>
>     Thank you,
>
>     Ernie Woods
>
>     Forman, Inc.
>
>     Sr. Programmer/Analyst
>
>
>     Service
>
>
> ProcessXMLStringToDB
>
> Test
>
>     To test the operation using the HTTP POST protocol, click the 'Invoke'
>     button.
>
>     Parameter
>
>     Value
>
>     Doc:
>
> SOAP 1.1
>
>     The following is a sample SOAP 1.1 request and response. The
>     placeholders shown need to be replaced with actual values.
> POST /service.asmx HTTP/1.1
> Host: xxx.126.154.120
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
> SOAPAction: "http://tempuri.org/ProcessXMLStringToDB";
>
> <?xml version="1.0" encoding="utf-8"?>
> <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>
>      <ProcessXMLStringToDB xmlns="http://tempuri.org/";>
>        <Doc>string</Doc>
>      </ProcessXMLStringToDB>
>    </soap:Body>
> </soap:Envelope>
> HTTP/1.1 200 OK
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
>
> <?xml version="1.0" encoding="utf-8"?>
> <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>
>      <ProcessXMLStringToDBResponse xmlns="http://tempuri.org/";>
>        <ProcessXMLStringToDBResult>string</ProcessXMLStringToDBResult>
>      </ProcessXMLStringToDBResponse>
>    </soap:Body>
> </soap:Envelope>
>
> SOAP 1.2
>
>     The following is a sample SOAP 1.2 request and response. The
>     placeholders shown need to be replaced with actual values.
> POST /service.asmx HTTP/1.1
> Host: xxx.126.154.120
> Content-Type: application/soap+xml; charset=utf-8
> Content-Length: length
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xs
> d="http://www.w3.org/2001/XMLSchema"; xmlns:soap12="http://www.w3.org/2003/05/so
> ap-envelope">
>    <soap12:Body>
>      <ProcessXMLStringToDB xmlns="http://tempuri.org/";>
>        <Doc>string</Doc>
>      </ProcessXMLStringToDB>
>    </soap12:Body>
> </soap12:Envelope>
> HTTP/1.1 200 OK
> Content-Type: application/soap+xml; charset=utf-8
> Content-Length: length
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xs
> d="http://www.w3.org/2001/XMLSchema"; xmlns:soap12="http://www.w3.org/2003/05/so
> ap-envelope">
>    <soap12:Body>
>      <ProcessXMLStringToDBResponse xmlns="http://tempuri.org/";>
>        <ProcessXMLStringToDBResult>string</ProcessXMLStringToDBResult>
>      </ProcessXMLStringToDBResponse>
>    </soap12:Body>
> </soap12:Envelope>
>
> HTTP GET
>
>     The following is a sample HTTP GET request and response. The
>     placeholders shown need to be replaced with actual values.
> GET /service.asmx/ProcessXMLStringToDB?Doc=string HTTP/1.1
> Host: xxx.126.154.120
> HTTP/1.1 200 OK
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
>
> <?xml version="1.0" encoding="utf-8"?>
> <string xmlns="http://tempuri.org/";>string</string>
>
> HTTP POST
>
>     The following is a sample HTTP POST request and response. The
>     placeholders shown need to be replaced with actual values.
> POST /service.asmx/ProcessXMLStringToDB HTTP/1.1
> Host: xxx.126.154.120
> Content-Type: application/x-www-form-urlencoded
> Content-Length: length
>
> Doc=string
> HTTP/1.1 200 OK
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
>
> <?xml version="1.0" encoding="utf-8"?>
> <string xmlns="http://tempuri.org/";>string</string>
>
>
>
>     THE RPG PROGRAM:
>
>     H BNDDIR('HTTPAPI')
>
>
>
>
>      **
>
>      **    CRTBNDRPG CUSTPRODHR SRCFILE(libhttp/QRPGLESRC) DBGVIEW(*LIST)
>     +
>
>     **       DFTACTGRP(*NO) ACTGRP(*NEW)
>
>
>
>
>     D/copy qrpglesrc,httpapi_h
>
>
>     D/copy qrpglesrc,ifsio_h
>
>     D/copy qrpglesrc,errno_h
>
>
>
>
>     D cmd             pr                  extpgm('QCMDEXC')
>
>     D  command                     200A   const
>
>     D  length                       15P 5 const
>
>
>
>
>     D ContentType     s             64A
>
>     D rc              s             10I 0
>
>     D msg             s             52A
>
>     D stmf            S            256A
>
>
>
>
>     C     *entry        plist
>
>     C                   parm                    p_inpcust         4
>
>
>
>
>      /free
>
>       *inlr = *on;
>
>
>
>       //** whatever data is in this stream file will
>
>       //** be POSTed to the URL below.
>
>       stmf = '/cgiforman/xmlexport/custprod'+p_inpcust+'.xml';
>
>       ContentType='application/x-www-form-urlencoded';
>
>
>
>       rc=http_url_post_stmf('http://xxx.126.154.120'
>
>         +'/service.asmx?op=ProcessXMLStringToDB'
>
>         : stmf
>
>         : '/tmp/http_result.txt'
>
>         : HTTP_TIMEOUT
>
>         : HTTP_USERAGENT
>
>         : ContentType );
>
>
>
>       if rc<>  1;
>
>          msg = http_error();
>
>          dsply msg;
>
>          return;
>
>       endif;
>
>
>
>       //unlink('/tmp/http_result.txt');
>
>       return;
>
>
>
>        This transmission contains information from Forman, Inc. which may be
>        confidential and/or privileged. The information is intended to be for the
>        exclusive use of the planned recipient. If you are not the intended
>        recipient, be advised that any disclosure, copying, distribution or other
>        use of this information is strictly prohibited. If you have received this
>        transmission in error, please notify the sender immediately.
>
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------


This transmission contains information from Forman, Inc. which may be confidential and/or privileged. The information is intended to be for the exclusive use of the planned recipient. If you are not the intended recipient, be advised that any disclosure, copying, distribution or other use of this information is strictly prohibited. If you have received this transmission in error, please notify the sender immediately.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------