What can I call a web service from iSeries COBOL?

We need to be able to call the internal web service from COBOL code running on the LPAR iSeries (V6R1). I worked out one complete example of what I managed to find online here . So, my next step was to try to repeat the process and call one of our existing web services.

I used the WSDL2WS command from QSH to create client C stubs. I changed the COBOL client program example and tried to call my web service. The problem I am facing seems to be that the returned pointers of Example C return pointers, and the COBOL code assigns them to pointers. I suspect that the error in my COBOL code is the root of my problem, because the C method created by WSDL2WS for my web service method returns a simple xsdc_string, and not a pointer to its own result type:

xsdc__string TestUnsuccessfulMessage(AXISCHANDLE stub)
{
    AXISCHANDLE call = axiscStubGetCall(stub);
    xsdc__string Ret = NULL;

    axiscCallSetSoapFaultNamespace(call, "http://myserver/PSItemMaintenance/ItemMaintenanceService.svc");


    // ======================================================================
    // Initialize client engine, set SOAP version, SOAPAction, operation, etc.
    // ======================================================================

    if (AXISC_SUCCESS != axiscCallInitialize(call, C_DOC_PROVIDER ))
        return Ret;

    if (NULL==axiscCallGetTransportProperty(call,"SOAPAction",0))
        axiscCallSetTransportProperty(call,AXISC_SOAPACTION_HEADER , "http://tempuri.org/IItemMaintenanceService/TestUnsuccessfulMessage");

    axiscCallSetSOAPVersion(call, SOAP_VER_1_1);
    axiscCallSetOperation(call, "TestUnsuccessfulMessage", "http://tempuri.org/");

    // ======================================================================
    // Apply SSL configuration properties and user-set SOAP headers.
    // ======================================================================

    axiscStubIncludeSecure(stub);
    axiscStubApplyUserPreferences(stub);


    // ======================================================================
    // Invoke web service, send/receive operation. Handle output parameters, if any.
    // ======================================================================

    if (AXISC_SUCCESS == axiscCallSendAndReceive(call))
    {
        if(AXISC_SUCCESS == axiscCallValidateMessage(call, "TestUnsuccessfulMessageResponse", "http://tempuri.org/", true_))
        {
            Ret = axiscCallGetElementAsString(call, "TestUnsuccessfulMessageResult", 0);
        }

        axiscStubCheckForExtraneousElements(stub);
    }
    axiscCallUnInitialize(call);
    return Ret;
}

I can configure the web service in debug mode and see a call from iSeries when starting a program that calls the COBOL and C modules. I also see that I am returning a simple string value.

, COBOL . , COBOL:

LINKAGE PROCEDURE FOR "TestSuccessfulMessage"
                 USING ALL DESCRIBED    

LINKAGE SECTION.                     
 01 LookupResult         PIC X(1000).  

CALL PROCEDURE "TestSuccessfulMessage"
 USING BY VALUE STUB              
 RETURNING LookupResult.          

MCH3601, . , LookupResult, .

, - . COBOL. . , , . .

: LookupResult . MCH3601, . iSeries (, ..) .

LookupResult linkage . "SET- LookupResult To ResultPointer". , , LookupResult, . , , LookupResult. SOAP-.

: , , COBOL. :

WORKING-STORAGE SECTION.              
01 Endpoint             PIC X(100).   
01 STUB                 USAGE POINTER.
01 ResultPointer        USAGE POINTER.

LINKAGE SECTION.                      
01 pszEndpoint          PIC X(100).   
01 LookupResult         PIC X(7).   

CALL PROCEDURE "TestSuccessfulMessage"       
     USING BY VALUE STUB                     
     RETURNING INTO ResultPointer.           

SET Address of LookupResult TO ResultPointer.
+5
1

, LookupResult, .

COBOL, iSeries. emptor.

xsdc__string , COBOL POINTER RETURNING CALL. , C NULL, , , - , axiscCallInitialize AXISC_SUCCESS.

, z/OS , COBOL , , ADDRESS of LookupResult TO . , , .

... FWIW

+4

All Articles