I've made Web Services with Delphi in the past but most were pretty simple that just took a few parameters and returned a single value to the client. A new service I am working on calls for me to be able to send and receive complex types. Consider the following types are defined in my code:
TBaseRequest = Class(TRemotable)
private
FUsername: string;
FPassword: string;
published
Property Username: String read FUsername write FUsername;
Property Password: String read FPassword write FPassword;
End;
TBaseResponse = Class(TRemotable)
private
FStatusMessage: string;
FStatusCode: integer;
published
Property StatusMessage: string read FStatusMessage write FStatusMessage;
Property StatusCode: integer read FStatusCode write FStatusCode;
End;
TSepecialRequest = class(TBaseRequest)
private
FExtraParam: string;
published
Property ExtraParam: String read FExtraParam write FExtraParam;
end;
TSpecialResponse = class(TBaseResponse)
private
FExtraResult: string;
published
Property ExtraResult: String read FExtraResultwrite FExtraResult;
end;
All of these classes are registerd with RemClassRegistry.RegisterXSClass.
Now I've also got the following function defined in the interface for this webservice:
function SpecialMethod(request:TSepecialRequest): TSpecialResponse;
In the service code I can easily access the parent class properties like Username and Password, but if we look at the WSDL that is generated we see that the TSpecialRequest and TSpecialResponse class members are included in the schema section.
<xs:complexType name="TSpecialRequest">
<xs:complexContent>
<xs:extension base="TBaseRequest">
<xs:sequence>
<xs:element name="ExtraParam" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TSpecialResponse">
<xs:complexContent>
<xs:extension base="TBaseResponse">
<xs:sequence>
<xs:element name="ExtraResult" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
This schema fragment in the WSDL shows that the TSpecials are extentions of the TBase classes and all is well except that the decription of the TBase classes are not included in the schema. I would expect there to also be a section like this, but it is missing:
<xs:complexType name="TBaseRequest">
<xs:sequence>
<xs:element name="Username" type="xs:string"/>
<xs:element name="Password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TBaseResponse">
<xs:sequence>
<xs:element name="StatusMessage" type="xs:string"/>
<xs:element name="StatusCode" type="xs:int"/>
</xs:sequence>
</xs:complexType>
However this schema fragment is missing from the generated WSDL. This means that any client attempting to use this service will not be able to correctly generate requests or interpret responses. For example, if I attempt to load the geneated WSDL into the WSDL importer in Delphi 2009, I get the following classes:
TSpecialRequest = class(TRemotable)
private
FExtraParam: WideString;
published
property ExtraParam: WideString read FExtraParam write FExtraParam;
end;
TSpecialResponse = class(TRemotable)
private
FStatusMessage: WideString;
FStatusCode: Integer;
published
property StatusMessag: WideString read FStatusMessage write FStatusMessage;
property StatusCode: Integer read FStatusCode write FStatusCode;
end;
The result is that the client code is unable to do things like set the username and password members that should be part of TSpecialRequest.
Does anyone have any clue why this is happening or what I can do about it?