Topic
  • 12 replies
  • Latest Post - ‏2011-10-27T00:32:43Z by amra1
dm400
dm400
9 Posts

Pinned topic RPGLE stub for WebService client + HTTP 401 Error

‏2011-06-30T11:46:38Z |
Hi All,
There is a very simple webservice to be access from following URL using rpgle
(wsdl file is also attached)


http:
//10.1.144.36:8000/sap/bc/soap/rfc?wsdl


To access above URL from firefox, it has to be give a user name & passwords
(Basic authentication required by webserver)

When I generate rpgle stub from wsdl2rpg tool, how can I pass a User name & password?

I tried it in following code but end-up with a error..

/QIBM/ProdData/OS/WebServices/V1/client/BIN/wsdl2rpg.sh -t90 -o/home/MANJULA/CSRC/SAP3 -s/QSYS.LIB/MANJULA.LIB/SAP3.SRVPGM http:
//10.1.144.36:8000/sap/bc/soap/rfc?wsdl



java.io.IOException: Server returned HTTP response code: 401 

for URL: http:
//10.1.144.36:8000/sap/bc/soap/rfc?wsdl

Anyone has suggestions or ideas on how to access secured webService from rpgle?

Thanks

Attachments

Updated on 2011-10-27T00:32:43Z at 2011-10-27T00:32:43Z by amra1
  • amra1
    amra1
    45 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-06-30T16:28:59Z  
    You will have to probably access the URL via browser, which should prompt you for userid/password, then view the page source and save that into a file on the IBM i. Then point to that file.
  • dm400
    dm400
    9 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-06-30T16:58:09Z  
    • amra1
    • ‏2011-06-30T16:28:59Z
    You will have to probably access the URL via browser, which should prompt you for userid/password, then view the page source and save that into a file on the IBM i. Then point to that file.
    Yes I have User name & password but few question as well
    01).
    If WSDL documents have an associated XSD, do I have to download all XSD into single IFS directory ?
    If run wsdl2rpg on saved wsdl file, will it find the associated XSD accordingly?

    02).
    say If I use that methods for simple wsdl file ( no XSD ), there should have a methods to authentication but my ZUAL_TEST_WEBSERVICEPortType.rpgleinc file doesn't have PR for that

    my RPG pgm is looks like this

    
    WsStub.endpoint = 
    'http://10.1.144.36:8000/sap/bc/soap/rfc';   ConN = stub_create_ZUAL_TEST_WEBSERVICEPortType(WsStub); 
    
    if (ConN = *On); ds_In.isNil_ZUAL_TEST_WEBSERVICE_t_t = *Off; DS_IN.LTEXT_IN.ISNIL = *Off; ds_In.LTEXT_IN.Value =
    'Test String';   
    
    if (stub_op_ZUAL_TEST_WEBSERVICE(WsStub : ds_In : ds_Out)); wsMSG  = %trim( ds_Out.LTEXT_OUT.value ) ; 
    
    else; wsMSG  = WsStub.excString; Endif; dsply wsMSG;   stub_destroy_ZUAL_TEST_WEBSERVICEPortType(WsStub); EndIf;
    


    WsStub.excString gives following Error.

    
    HTTPTransportException: HTTP transport error.Server sent HT TP error: 
    'Unauthorized'
    


    Thanks
  • dm400
    dm400
    9 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-01T03:53:12Z  
    • amra1
    • ‏2011-06-30T16:28:59Z
    You will have to probably access the URL via browser, which should prompt you for userid/password, then view the page source and save that into a file on the IBM i. Then point to that file.
    Hi amra1,
    I'm confused about the behavior of this tool, I download the wsdl & generate the stub but there is no PR to send authentication. Due to this reason the invoke program blew up with this error
    
    HTTPTransportException: HTTP transport error.¬Server sent HTTP error: 
    'Unauthorized'
    

    Thought it is because of offline generation (download to ifs & so on). So I tried with giving the actual URL but end up with error that I posted in my first post. cause there are no way to send authentication detail at that point

    If I’m understood correctly, your suggestion will work for webServiceses that doesn’t have XSD. And we can generate the stub accordingly.
    But how will the invoke program looks like?
    the generated *.rpgleinc will not have PR to send authentication to the server.

    And this tool doesn’t work with the WSDL documents that have an associated XSD?

    Please correct me if I’m wrong..

    Thanks
  • dm400
    dm400
    9 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-01T12:26:32Z  
    • dm400
    • ‏2011-07-01T03:53:12Z
    Hi amra1,
    I'm confused about the behavior of this tool, I download the wsdl & generate the stub but there is no PR to send authentication. Due to this reason the invoke program blew up with this error
    <pre class="jive-pre"> HTTPTransportException: HTTP transport error.¬Server sent HTTP error: 'Unauthorized' </pre>
    Thought it is because of offline generation (download to ifs & so on). So I tried with giving the actual URL but end up with error that I posted in my first post. cause there are no way to send authentication detail at that point

    If I’m understood correctly, your suggestion will work for webServiceses that doesn’t have XSD. And we can generate the stub accordingly.
    But how will the invoke program looks like?
    the generated *.rpgleinc will not have PR to send authentication to the server.

    And this tool doesn’t work with the WSDL documents that have an associated XSD?

    Please correct me if I’m wrong..

    Thanks
    Stub Generation was Success

    OKKK... finally change the url to have user name & password & it was success.
    it says "Code generation completed. Generated files in directory"
    
    http:
    //UAL_RFC:sapsap12@10.1.144.36:8000/sap/bc/srt/wsdl/bndg_...
    


    but now there is a new issues..
    
    Attempting to create service program... java.lang.RuntimeException: CL command failed to run successfully. Module WSC2 is not created because statement errors occurred. The compilation failed. Service program creation failed. Please see errors above.
    


    then i check the spool & it shows
    
    RNF7030 30   1572 000078+ The name or indicator CHAR20 is not defined. RNF7030 30   2430 000260  The name or indicator VALUE0@ is not defined.
    


    in the source char20 is define like this
    
    D stub_op_ZualTestWebservice... D                 PR             1N   extproc(
    'ZualTestWebservice@') D 
    
    this                                likeds(This_t) D Value0                              likeds(char20) D out                                 likeds(xsd_string)
    


    from wsdl char20 is define like this
    
    <wsdl:types> <xsd:schema attributeFormDefault=
    "qualified" targetNamespace=
    "urn:sap-com:document:sap:rfc:functions"> <xsd:simpleType name=
    "char20"> <xsd:restriction base=
    "xsd:string"> <xsd:maxLength value=
    "20"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>
    


    I checked the ..xsdtypes.rpgleinc file but it doesn't have char20 data type in it..

    any idea?
  • JonParis
    JonParis
    117 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-01T17:06:01Z  
    • dm400
    • ‏2011-07-01T12:26:32Z
    Stub Generation was Success

    OKKK... finally change the url to have user name & password & it was success.
    it says "Code generation completed. Generated files in directory"
    <pre class="jive-pre"> http: //UAL_RFC:sapsap12@10.1.144.36:8000/sap/bc/srt/wsdl/bndg_... </pre>

    but now there is a new issues..
    <pre class="jive-pre"> Attempting to create service program... java.lang.RuntimeException: CL command failed to run successfully. Module WSC2 is not created because statement errors occurred. The compilation failed. Service program creation failed. Please see errors above. </pre>

    then i check the spool & it shows
    <pre class="jive-pre"> RNF7030 30 1572 000078+ The name or indicator CHAR20 is not defined. RNF7030 30 2430 000260 The name or indicator VALUE0@ is not defined. </pre>

    in the source char20 is define like this
    <pre class="jive-pre"> D stub_op_ZualTestWebservice... D PR 1N extproc( 'ZualTestWebservice@') D this likeds(This_t) D Value0 likeds(char20) D out likeds(xsd_string) </pre>

    from wsdl char20 is define like this
    <pre class="jive-pre"> <wsdl:types> <xsd:schema attributeFormDefault= "qualified" targetNamespace= "urn:sap-com:document:sap:rfc:functions"> <xsd:simpleType name= "char20"> <xsd:restriction base= "xsd:string"> <xsd:maxLength value= "20"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> </pre>

    I checked the ..xsdtypes.rpgleinc file but it doesn't have char20 data type in it..

    any idea?
    Not wishing to rain on this particular parade - but why don't you post your questions on Scott Klement's API list? I'm sure you'd get better responses as many of the folks there use this tool - not to mention the fact that WSDL2RPG's author is a regular contributor.

    Just a thought - go to http://www.scottklement.com/mailman/listinfo/ftpapi to sign up.
  • dm400
    dm400
    9 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-01T17:24:08Z  
    • JonParis
    • ‏2011-07-01T17:06:01Z
    Not wishing to rain on this particular parade - but why don't you post your questions on Scott Klement's API list? I'm sure you'd get better responses as many of the folks there use this tool - not to mention the fact that WSDL2RPG's author is a regular contributor.

    Just a thought - go to http://www.scottklement.com/mailman/listinfo/ftpapi to sign up.
    I thought HTTPAPI + WSDL2RPG tool and the WSDL2RPG tool from IBM PTF : SI42234 were different tools
    am i wrong?

    Thanks
  • JonParis
    JonParis
    117 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-01T17:57:06Z  
    • dm400
    • ‏2011-07-01T17:24:08Z
    I thought HTTPAPI + WSDL2RPG tool and the WSDL2RPG tool from IBM PTF : SI42234 were different tools
    am i wrong?

    Thanks
    Sorry - didn't realize you were talking about the IBM tool.

    Shows what happens when IBM foolishly use a name that was already well established in the marketplace.
  • Sibat
    Sibat
    1 Post

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-07-11T20:39:21Z  
    I have used the WSDL2RPG tool. you will find it a lot easier to work with, here is the link
    http://www.tools400.de/English/Freeware/WSDL2RPG/wsdl2rpg.html
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-10-17T13:43:31Z  
    • dm400
    • ‏2011-07-01T12:26:32Z
    Stub Generation was Success

    OKKK... finally change the url to have user name & password & it was success.
    it says "Code generation completed. Generated files in directory"
    <pre class="jive-pre"> http: //UAL_RFC:sapsap12@10.1.144.36:8000/sap/bc/srt/wsdl/bndg_... </pre>

    but now there is a new issues..
    <pre class="jive-pre"> Attempting to create service program... java.lang.RuntimeException: CL command failed to run successfully. Module WSC2 is not created because statement errors occurred. The compilation failed. Service program creation failed. Please see errors above. </pre>

    then i check the spool & it shows
    <pre class="jive-pre"> RNF7030 30 1572 000078+ The name or indicator CHAR20 is not defined. RNF7030 30 2430 000260 The name or indicator VALUE0@ is not defined. </pre>

    in the source char20 is define like this
    <pre class="jive-pre"> D stub_op_ZualTestWebservice... D PR 1N extproc( 'ZualTestWebservice@') D this likeds(This_t) D Value0 likeds(char20) D out likeds(xsd_string) </pre>

    from wsdl char20 is define like this
    <pre class="jive-pre"> <wsdl:types> <xsd:schema attributeFormDefault= "qualified" targetNamespace= "urn:sap-com:document:sap:rfc:functions"> <xsd:simpleType name= "char20"> <xsd:restriction base= "xsd:string"> <xsd:maxLength value= "20"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> </pre>

    I checked the ..xsdtypes.rpgleinc file but it doesn't have char20 data type in it..

    any idea?
    Hi there!

    Hope you'll go the things to work by now.
    When I used the command I noticed that, If I ran the command twice with different parameter settings some of the settings would remain from the first run.
    So if you first had an unsuccesful run, and run again, with the same path settings to the source catalog, not all your new settings will be in the new source.
    I had to delete all generated source prior running the WSDS2xx.sh
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-10-18T12:09:45Z  
    • dm400
    • ‏2011-07-01T12:26:32Z
    Stub Generation was Success

    OKKK... finally change the url to have user name & password & it was success.
    it says "Code generation completed. Generated files in directory"
    <pre class="jive-pre"> http: //UAL_RFC:sapsap12@10.1.144.36:8000/sap/bc/srt/wsdl/bndg_... </pre>

    but now there is a new issues..
    <pre class="jive-pre"> Attempting to create service program... java.lang.RuntimeException: CL command failed to run successfully. Module WSC2 is not created because statement errors occurred. The compilation failed. Service program creation failed. Please see errors above. </pre>

    then i check the spool & it shows
    <pre class="jive-pre"> RNF7030 30 1572 000078+ The name or indicator CHAR20 is not defined. RNF7030 30 2430 000260 The name or indicator VALUE0@ is not defined. </pre>

    in the source char20 is define like this
    <pre class="jive-pre"> D stub_op_ZualTestWebservice... D PR 1N extproc( 'ZualTestWebservice@') D this likeds(This_t) D Value0 likeds(char20) D out likeds(xsd_string) </pre>

    from wsdl char20 is define like this
    <pre class="jive-pre"> <wsdl:types> <xsd:schema attributeFormDefault= "qualified" targetNamespace= "urn:sap-com:document:sap:rfc:functions"> <xsd:simpleType name= "char20"> <xsd:restriction base= "xsd:string"> <xsd:maxLength value= "20"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> </pre>

    I checked the ..xsdtypes.rpgleinc file but it doesn't have char20 data type in it..

    any idea?
    Can you find the CHAR20 ds in your source listing. The source you listed was a ds that used the char20 ds. you need to find the ds that represents CHAR20.

    I have found that depending on the WSDL it will give the WSDL2SH/WSDL2RPG some problems when generating the RPG stubs. The c stubs will generate, mostly, without any issues. Depending on how complex the elements are in the WSDL depends on the success of the auto-generated code.
  • amra1
    amra1
    45 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-10-27T00:30:44Z  
    Can you find the CHAR20 ds in your source listing. The source you listed was a ds that used the char20 ds. you need to find the ds that represents CHAR20.

    I have found that depending on the WSDL it will give the WSDL2SH/WSDL2RPG some problems when generating the RPG stubs. The c stubs will generate, mostly, without any issues. Depending on how complex the elements are in the WSDL depends on the success of the auto-generated code.
    You should load latest PTFs that fixes some things with rpg stub generation:

    SI45077 7.1
    SI44902 6.1
    SI44903 5.4
  • amra1
    amra1
    45 Posts

    Re: RPGLE stub for WebService client + HTTP 401 Error

    ‏2011-10-27T00:32:43Z  
    Hi there!

    Hope you'll go the things to work by now.
    When I used the command I noticed that, If I ran the command twice with different parameter settings some of the settings would remain from the first run.
    So if you first had an unsuccesful run, and run again, with the same path settings to the source catalog, not all your new settings will be in the new source.
    I had to delete all generated source prior running the WSDS2xx.sh
    Yes, it is true if you run the command once, it will generate file, and if you do so again, it does NOT delete anything in the directory you specify. So ensure that you specify a different out-directory or delete the old directory before issuing the command again.