Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem passing array of objects soap between java (axis) and delphi

245 views
Skip to first unread message

Christoph Donges

unread,
Jan 10, 2004, 3:07:38 AM1/10/04
to
I have a java soap server using axis and a delphi client that's tring to
connect to it. For simple stuff it seems to work fine but when I try to
pass an array of objects I get the error "A name contained an invalid
character" and then the first line of what looks like html.

Can someone help me, or am I just pushing soap too far? Have other
people successfully passed arrays of objects?

The Comps method fails, but the z method (that just returns a string) works.

Below is the wsdl and source:

WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://localhost:8080/axis/Tipping.jws"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost:8080/axis/Tipping.jws"
xmlns:intf="http://localhost:8080/axis/Tipping.jws"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns1="http://tipping"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><wsdl:types><schema
targetNamespace="http://tipping"
xmlns="http://www.w3.org/2001/XMLSchema"><import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType
name="Competition"><sequence><element name="compName" nillable="true"
type="xsd:string"/><element name="member"
type="xsd:boolean"/></sequence></complexType></schema><schema
targetNamespace="http://localhost:8080/axis/Tipping.jws"
xmlns="http://www.w3.org/2001/XMLSchema"><import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType
name="ArrayOf_tns1_Competition"><complexContent><restriction
base="soapenc:Array"><attribute ref="soapenc:arrayType"
wsdl:arrayType="tns1:Competition[]"/></restriction></complexContent></complexType></schema></wsdl:types>
<wsdl:message name="zRequest">
<wsdl:part name="user" type="xsd:string"/>
<wsdl:part name="pass" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="zResponse">
<wsdl:part name="zReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="CompsResponse">

<wsdl:part name="CompsReturn" type="impl:ArrayOf_tns1_Competition"/>
</wsdl:message>
<wsdl:message name="CompsRequest">
<wsdl:part name="user" type="xsd:string"/>
<wsdl:part name="pass" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="Tipping">
<wsdl:operation name="z" parameterOrder="user pass">
<wsdl:input message="impl:zRequest" name="zRequest"/>

<wsdl:output message="impl:zResponse" name="zResponse"/>
</wsdl:operation>
<wsdl:operation name="Comps" parameterOrder="user pass">
<wsdl:input message="impl:CompsRequest" name="CompsRequest"/>
<wsdl:output message="impl:CompsResponse" name="CompsResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TippingSoapBinding" type="impl:Tipping">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="z">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="zRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="zResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/Tipping.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>

<wsdl:operation name="Comps">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="CompsRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="CompsResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/Tipping.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>

</wsdl:binding>
<wsdl:service name="TippingService">
<wsdl:port binding="impl:TippingSoapBinding" name="Tipping">
<wsdlsoap:address location="http://localhost:8080/axis/Tipping.jws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


Competition.java:
package tipping;

public class Competition implements java.io.Serializable {
private String compName;
private boolean member;

public Competition() {
}

public Competition(String compName, boolean member) {
this.compName = compName;
this.member = member;
}

public boolean getMember() {
return member;
}

public void setMember(boolean member) {
this.member = member;
}

public String getCompName() {
return compName;
}

public void setCompName(String compName) {
this.compName = compName;
}

}


Tipping.jws:
import tipping.*;

public class Tipping {
public Competition[] Comps(String user, String pass) {
Competition returnArray[] = new Competition[1];
returnArray[0] = new Competition(user+pass,true);
return returnArray;
}
public String z(String user, String pass) {
return user+pass;
}
}


Tipping1.pas:
//
************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/axis/Tipping.jws?wsdl
// Encoding : UTF-8
// Version : 1.0
// (10/01/2004 5:51:44 PM - 1.33.2.5)
//
************************************************************************ //

unit Tipping1;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

//
************************************************************************ //
// The following types, referred to in the WSDL document are not
being represented
// in this file. They are either aliases[@] of other types
represented or were referred
// to but never[!] declared in the document. The types from the
latter category
// typically map to predefined/known XML or Borland types; however,
they could also
// indicate incorrect WSDL documents that failed to declare or import
a schema type.
//
************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:boolean - "http://www.w3.org/2001/XMLSchema"

Competition = class; { "http://tipping" }

//
************************************************************************ //
// Namespace : http://tipping
//
************************************************************************ //
Competition = class(TRemotable)
private
FcompName: WideString;
Fmember: Boolean;
published
property compName: WideString read FcompName write FcompName;
property member: Boolean read Fmember write Fmember;
end;

ArrayOf_tns1_Competition = array of Competition; {
"http://localhost:8080/axis/Tipping.jws" }

//
************************************************************************ //
// Namespace : http://DefaultNamespace
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : TippingSoapBinding
// service : TippingService
// port : Tipping
// URL : http://localhost:8080/axis/Tipping.jws
//
************************************************************************ //
Tipping = interface(IInvokable)
['{53E0B23C-2024-98C4-914B-0BB09664C548}']
function z(const user: WideString; const pass: WideString):
WideString; stdcall;
function Comps(const user: WideString; const pass: WideString):
ArrayOf_tns1_Competition; stdcall;
end;

function GetTipping(UseWSDL: Boolean=System.False; Addr: string='';
HTTPRIO: THTTPRIO = nil): Tipping;


implementation

function GetTipping(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO):
Tipping;
const
defWSDL = 'http://localhost:8080/axis/Tipping.jws?wsdl';
defURL = 'http://localhost:8080/axis/Tipping.jws';
defSvc = 'TippingService';
defPrt = 'Tipping';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as Tipping);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(Tipping),
'http://DefaultNamespace', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Tipping), '');
RemClassRegistry.RegisterXSClass(Competition, 'http://tipping',
'Competition');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOf_tns1_Competition),
'http://localhost:8080/axis/Tipping.jws', 'ArrayOf_tns1_Competition');

end.

Unit1.pas:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls,tipping1;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
c:ArrayOf_tns1_Competition;
t:Tipping;
begin
SetLength(c,20);
t := GetTipping(true);
c := t.Comps('aa','aa');
showmessage(c[0].compName);

showmessage(t.z('zz','xx'));
c := nil;
end;

end.

Roger Webb

unread,
Jan 26, 2004, 4:09:01 PM1/26/04
to

"Christoph Donges" <ne...@arilan.com> wrote in message
news:3fff...@newsgroups.borland.com...

> I have a java soap server using axis and a delphi client that's tring to
> connect to it. For simple stuff it seems to work fine but when I try to
> pass an array of objects I get the error "A name contained an invalid
> character" and then the first line of what looks like html.

Sounds like a data problem.. Some character inside your data that when
converted across XML is not a valid character... My guess is it might be
like a quote in dad like ... Roger's ... which would make some wierdness
happen. I'm guessing though.

> Can someone help me, or am I just pushing soap too far? Have other
> people successfully passed arrays of objects?

No.. You arent pushing soap to hard. We are passing objects back and forth
over soap...and even lists of objects from axis to a Delphi Client. The
implementation of Delphi 7 Soap out of the box wasnt to fast, we've sped it
up quite a bit. But, we are passing large arrays *Fairly* quickly.

As far as the rest of the posting... I'm no expert, however, I'll be happy
to look... We;ve just started our soap implementation on a small scale.. but
have big dreams for it.


- Roger Webb
Texas Windstorm Insurance Association
MSN: TxWh...@hotmail.com

0 new messages