Skip to main content

Problem:

COBOL Web Service Clients default to PIC X(100) for Strings. This can cause issues as more than 100 characters may be returned in a string.

Resolution:

You can amend the WSDL for a WebService to specify the expected string size and then generate the COBOL Client from the amended  WSDL.

An example of this is below:-

<?xml version="1.0"?>

<definitions name="CATrafficService" targetNamespace="http://www.xmethods.net/sd/CATrafficService.wsdl" xmlns:tns="http://www.xmethods.net/sd/CATrafficService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:new="new">

<types>

<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="new">

<simpleType name="string2">

<restriction base="string">

<length value="1000"/>

</restriction>

</simpleType>

</schema>

</types>

<message name="getTrafficRequest">

<part name="hwynums" type="xsd:string"/>

</message>

<message name="getTrafficResponse">

<part name="return" type="new:string2"/>

</message>

<portType name="CATrafficPortType">

<operation name="getTraffic">

<input message="tns:getTrafficRequest" name="getTraffic"/>

<output message="tns:getTrafficResponse" name="getTrafficResponse"/>

</operation>

</portType>

<binding name="CATrafficBinding" type="tns:CATrafficPortType">

<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="getTraffic">

<soap:operation soapAction="" />

<input name="getTraffic">

<soap:body use="encoded" namespace="urn:xmethods-CATraffic" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

</input>

<output name="getTrafficResponse">

<soap:body use="encoded" namespace="urn:xmethods-CATraffic" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

</output>

</operation>

</binding>

<service name="CATrafficService">

<documentation>Provides information on California Highway Conditions.</documentation>

<port name="CATrafficPort" binding="tns:CATrafficBinding">

<soap:address location="http://services.xmethods.net:80/soap/servlet/rpcrouter"/>

</port>

</service>

</definitions>

You can see that here we have added the new type "Strings" in the "new" namespace that has a size of 1000. The return string is specified to be of this new type.

When the COBOL Web Service client is generated from this WSDL it will be of the type PIC X(1000).

Old KB# 7087