Webservice Datasource Problem

Hi,

I have a Werbservice (incomplete at the moment, it only implements the fetch method)

WSDL:

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap
/" xmlns:tns="http://config.ws.jobtrack.switchedonsystems.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 name="Config" targetNamespace="http://config.ws.jobtrack.switchedonsystems.com/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://config.ws.jobtrack.switchedonsystems.com/" schemaLocation="http:
//localhost:8080/Config/Department?xsd=Config_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="fetchResponse">
    <part element="tns:fetchResponse" name="parameters">
    </part>
  </message>
  <message name="fetch">
    <part element="tns:fetch" name="parameters">
    </part>
  </message>
  <portType name="Department">
    <operation name="fetch">
      <input message="tns:fetch">
    </input>
      <output message="tns:fetchResponse">
    </output>
    </operation>
  </portType>
  <binding name="DepartmentBinding" type="tns:Department">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="fetch">
      <soap:operation soapAction="fetch"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="Config">
    <port binding="tns:DepartmentBinding" name="Department">
      <soap:address location="http://localhost:8080/Config/Department"/>
    </port>
  </service>
</definitions>

Schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://config.ws.jobtrack.switchedonsystems.com/" xmlns:xs="http://www.w3.org/2001
/XMLSchema" targetNamespace="http://config.ws.jobtrack.switchedonsystems.com/" version="1.0">

  <xs:element name="fetch" type="tns:fetch"/>

  <xs:element name="fetchResponse" type="tns:fetchResponse"/>

  <xs:complexType name="fetch"/>

  <xs:complexType name="fetchResponse">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="departments" type="tns:department"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="department">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="categoryCollection" nillable="true" type
="tns:category"/>
      <xs:element name="departmentId" type="xs:long"/>
      <xs:element minOccurs="0" name="departmentName" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="category">
    <xs:sequence>
      <xs:element name="categoryId" type="xs:long"/>
      <xs:element minOccurs="0" name="categoryName" type="xs:string"/>
      <xs:element minOccurs="0" name="default_" type="tns:priority"/>
      <xs:element minOccurs="0" name="departmentId" type="tns:department"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="priority">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="categoryCollection" nillable="true" type
="tns:category"/>
      <xs:element name="priorityId" type="xs:long"/>
      <xs:element minOccurs="0" name="priorityName" type="xs:string"/>
      <xs:element name="priorityOrder" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

This is accessed through a subclass of WSDataSource:

public class DepartmentPropertyDS extends WSDataSource {
	
	public DepartmentPropertyDS () {
		super();
		
		
		setServiceNamespace("http://config.ws.jobtrack.switchedonsystems.com/");
		setDataFormat(DSDataFormat.XML);
		setDataProtocol(DSProtocol.SOAP);
		setDataTransport(RPCTransport.XMLHTTPREQUEST);
		setDataURL("/Config/Department");
		setRecordXPath("/*");
		setRecordName("departments");
		
		DataSourceIntegerField depId = new DataSourceIntegerField ("departmentId","Department ID");
		depId.setPrimaryKey(true);
		addField(depId);
		
		
		addField(new DataSourceTextField ("departmentName", "Department Name (DS)"));

	}
	
}

Which in turn is the datasource of a ListGrid.

I can see in firebug, that WSDL and Schema are loaded. I see this request being sent to the server:

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header></soap:Header>
    <soap:Body
                 xmlns:ns0="http://config.ws.jobtrack.switchedonsystems.com/">
        <ns0:fetch>
            <dataSource>isc_OID_64</dataSource>
            <operationType>fetch</operationType>
            <data></data>
            <startRow>0</startRow>
            <endRow>75</endRow>
        </ns0:fetch>
    </soap:Body>
</soap:Envelope>

and this response being sent back (formated for better readability):

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap
/envelope/">
	<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
		<ns2:fetchResponse xmlns:ns2="http://config.ws.jobtrack.switchedonsystems.com/">
			<departments>
				<departmentId>1</departmentId>
				<departmentName>TEst</departmentName>
			</departments>
			<departments>
				<departmentId>2</departmentId>
				<departmentName>Test 2</departmentName>
			</departments>
		</ns2:fetchResponse>
	</soapenv:Body>
</soapenv:Envelope>

The ListGrid does not show any items in its list. I have tried variations of the of setRecordXPath and setRecordName, nothing seems to yield a result.

Any suggestions and leads are welcome.

Roland

WSDataSource is designed specifically to talk to the SmartClientOperations.wsdl included in the SDK. To talk to another WSDL, start with just DataSource.

Use either recordName or recordXPath. Your recordName setting of departments looks right if you remove the recordXPath and use the correct base class.

Be sure that you have loaded both the WSDL and the XSD. It doesn’t happen automatically.

Thanks a lot Isomorphic, I got this finally to work. This is the code that finally worked (for those who read this in the future :-))

public class DepartmentPropertyDS extends DataSource {
	
	public DepartmentPropertyDS () {
		super();
		
		try {
			setServiceNamespace("http://config.ws.jobtrack.switchedonsystems.com/");
			setDataFormat(DSDataFormat.XML);
			setDataProtocol(DSProtocol.SOAP);
			setDataTransport(RPCTransport.XMLHTTPREQUEST);
			setDataURL("/Config/Department");
			setRecordXPath("//departments");
			
			OperationBinding fetchBinding = new OperationBinding();
			fetchBinding.setOperationType(DSOperationType.FETCH);
			fetchBinding.setWsOperation("fetch");

			OperationBinding addBinding = new OperationBinding ();
			addBinding.setOperationType(DSOperationType.ADD);
			addBinding.setWsOperation("add");
			
			OperationBinding updateBinding = new OperationBinding ();
			updateBinding.setOperationType(DSOperationType.UPDATE);
			updateBinding.setWsOperation("update");
			
			OperationBinding deleteBinding = new OperationBinding ();
			deleteBinding.setOperationType(DSOperationType.REMOVE);
			deleteBinding.setWsOperation("delete");
			
			setOperationBindings(fetchBinding,addBinding,updateBinding,deleteBinding);
			
			DataSourceIntegerField depId = new DataSourceIntegerField ("departmentId","Department ID");
			depId.setPrimaryKey(true);
			addField(depId);
			
			addField(new DataSourceTextField ("departmentName", "Department Name (DS)"));
		} catch (Exception e ) {
			Window.alert(e.getMessage());
		}
	}
}