Hi Christophe, I tried many times on gsoap using -t, but it still send out message without xsi:type(maybe it's a gSoap bug), and I checked the other stuff, such as rpc/encoded, they all look right.
Do you think it's because of without xsi:type, that the client can not generate the right object? But I tried to send a 'Shape' object, the client can create a right 'Shape' instance, only if I send the derived class, then client has exception on it. By the way, can you tell me which soap server you used on the server side? I need a c/c++ soap server, so I can put on the embeded system. Thanks, Georgia -----Original Message----- From: Christophe Roudet [mailto:[EMAIL PROTECTED] Sent: Thursday, October 21, 2004 3:04 PM To: [EMAIL PROTECTED] Subject: RE: Does Axis support polymorphism (dynamic send back the derived class) I am sorry but have I have never used gsoap, so I can't help much more. Try to make a diff on the code generated by both commands. Also check that you are doing rpc/encoded style. <wsdl:binding name="xxxx" type="xxx"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="xxxx"> <wsdl:input name="xxx"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="xxx" use="encoded"/> </wsdl:input> <wsdl:output name="xxx"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="xxx" use="encoded"/> </wsdl:output> </wsdl:operation> ... Christophe > -----Original Message----- > From: Zhou Jian Han [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 21, 2004 5:53 PM > To: [EMAIL PROTECTED] > Subject: RE: Does Axis support polymorphism (dynamic send back the derived > class) > > Sorry Christophe, > I think I read the wrong one, the soapcpp2 does have -t to generates code > to send typed messages, but why it doesn't work, does my command wrong? > soapcpp2 -t polymorph.h > It looks like the output is same as I don't specify -t. > > Thanks, > Zhuojian > > -----Original Message----- > From: Zhou Jian Han [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 21, 2004 2:42 PM > To: [EMAIL PROTECTED] > Subject: RE: Does Axis support polymorphism (dynamic send back the > derived class) > > > Hi Christophe, > I tried use the comand: soapcpp2 -t polymorph.h > but it does not generate any xsi:type attribute. server still transfer > the same xml to client. > And I read the User Guide, it looks like I need to specify file after > -t, such as '-t file', > so it will use type map file instead of the default file typemap.dat, > but which file is it? Could you tell me where is the file which can use > xsi:type attribute? > > Thanks, > Georgia > > -----Original Message----- > From: Christophe Roudet [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 21, 2004 12:39 PM > To: [EMAIL PROTECTED] > Subject: RE: Does Axis support polymorphism (dynamic send back the > derived class) > > > When abstract is true, your java class must be declared abstract. It is > not > your case, so removed it. > Try to use gsoap soapcpp2 with flag -t to have typed messages, so your > messages will have xsi:type attributes. > > .. > <name xsi:type="soapenc:string">Cubicle</name> > <sides xsi:type="xsd:int">4</sides> > <size xsi:type="xsd:int">40</size> > ... > > Christophe > > > -----Original Message----- > > From: Zhou Jian Han [mailto:[EMAIL PROTECTED] > > Sent: Thursday, October 21, 2004 3:08 PM > > To: [EMAIL PROTECTED] > > Subject: RE: Does Axis support polymorphism (dynamic send back the > derived > > class) > > > > Hi Christophe, > > According to your suggestion, I took out the inherited fileds. and I > > checked my PolymorphStub.java, it does include both Shape and Square, > > see below: > > > > public PolymorphStub(javax.xml.rpc.Service service) throws > > org.apache.axis.AxisFault { > > if (service == null) { > > super.service = new org.apache.axis.client.Service(); > > } else { > > super.service = service; > > } > > java.lang.Class cls; > > javax.xml.namespace.QName qName; > > java.lang.Class beansf = > > org.apache.axis.encoding.ser.BeanSerializerFactory.class; > > java.lang.Class beandf = > > org.apache.axis.encoding.ser.BeanDeserializerFactory.class; > > java.lang.Class enumsf = > > org.apache.axis.encoding.ser.EnumSerializerFactory.class; > > java.lang.Class enumdf = > > org.apache.axis.encoding.ser.EnumDeserializerFactory.class; > > java.lang.Class arraysf = > > org.apache.axis.encoding.ser.ArraySerializerFactory.class; > > java.lang.Class arraydf = > > org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; > > java.lang.Class simplesf = > > org.apache.axis.encoding.ser.SimpleSerializerFactory.class; > > java.lang.Class simpledf = > > org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; > > qName = new javax.xml.namespace.QName("urn:copy", > "Shape"); > > cachedSerQNames.add(qName); > > cls = copy.Shape.class; > > cachedSerClasses.add(cls); > > cachedSerFactories.add(beansf); > > cachedDeserFactories.add(beandf); > > > > qName = new javax.xml.namespace.QName("urn:copy", > "Square"); > > cachedSerQNames.add(qName); > > cls = copy.Square.class; > > cachedSerClasses.add(cls); > > cachedSerFactories.add(beansf); > > cachedDeserFactories.add(beandf); > > > > } > > > > But when I run it, it still throw following: > > SEVERE: Exception: > > org.xml.sax.SAXException: Invalid element in copy.Shape - size > > at > > org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeseri > > alizer.java:260) > > at > > org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese > > rializationContextImpl.java:963) > > at > > org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja > > va:198) > > at > > org.apache.axis.message.MessageElement.publishToHandler(MessageElemen > > t.java:722) > > at > > org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233) > > at > > org.apache.axis.message.RPCElement.getParams(RPCElement.java:347) > > at org.apache.axis.client.Call.invoke(Call.java:2272) > > at org.apache.axis.client.Call.invoke(Call.java:2171) > > at org.apache.axis.client.Call.invoke(Call.java:1691) > > at copy.PolymorphStub.getPoly(PolymorphStub.java:143) > > at copy.Tester.main(Tester.java:18) > > Exception in thread "main" AxisFault > > ... > > > > I saw your first reply mail, you have abstract="true", so I add this > to > > .wsdl, see below: > > <complexType abstract="true" name="Shape"> > > <sequence> > > <element name="name" type="xsd:string" minOccurs="0" > maxOccurs="1" > > nillable="true"/> > > <element name="sides" type="xsd:int" minOccurs="1" > maxOccurs="1"/> > > </sequence> > > </complexType> > > <complexType name="Square"> > > <complexContent> > > <extension base="ns:Shape"> > > <sequence> > > <element name="size" type="xsd:int" minOccurs="1" maxOccurs="1"/> > > </sequence> > > </extension> > > </complexContent> > > </complexType> > > > > This time after I run it, it throws different exception: > > SEVERE: Exception: > > org.xml.sax.SAXException: Unable to create JavaBean of type > copy.Shape. > > Missing > > default constructor? Error was: java.lang.InstantiationException. > > at > > org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri > > alizer.java:159) > > at > > org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese > > rializationContextImpl.java:976) > > at > > org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja > > va:198) > > at > > org.apache.axis.message.MessageElement.publishToHandler(MessageElemen > > t.java:722) > > at > > org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233) > > at > > org.apache.axis.message.RPCElement.getParams(RPCElement.java:347) > > at org.apache.axis.client.Call.invoke(Call.java:2272) > > at org.apache.axis.client.Call.invoke(Call.java:2171) > > at org.apache.axis.client.Call.invoke(Call.java:1691) > > at copy.PolymorphStub.getPoly(PolymorphStub.java:143) > > at copy.Tester.main(Tester.java:18) > > Exception in thread "main" AxisFault > > > > I checked both Square.java and Shape.java, they do have default > > constructor, any idea? > > I don't know how to run tcpmonitor because every time my client open a > > random port, and I have no idea which port should I specify to > > listening when using tcpmonitor, so I use different tools to get the > > packet sending from the server, here are the sever reply xml: > > HTTP/1.1 200 OK > > Server: gSOAP/2.7 > > Content-Type: text/xml; charset=utf-8 > > Content-Length: 538 > > Connection: close > > > > <?xml version="1.0" encoding="UTF-8"?> > > <SOAP-ENV:Envelope > > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" > > xmlns:xsi="http://www.w3.org/2000/XMLSchema-instance" > > xmlns:xsd="http://www.w3.org/2000/XMLSchema" xmlns:ns="urn:copy"> > > <SOAP-ENV:Body > > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> > > <ns:polytestResponse> > > <out xsi:type="ns:Square"> > > <name>Cubicle</name> > > <sides>4</sides> > > <size>40</size> > > </out> > > </ns:polytestResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> > > > > > > Do you have any idea, why the axis still try to build "Shape" object > > instead of "Square"? and why it complain Missing default constructor > at > > second time? > > > > Thanks, > > Georgia > > > > -----Original Message----- > > From: Christophe Roudet [mailto:[EMAIL PROTECTED] > > Sent: Thursday, October 21, 2004 11:07 AM > > To: [EMAIL PROTECTED] > > Subject: RE: Does Axis support polymorphism (dynamic send back the > > derived class) > > > > > > I don't think you have to declare the inherited fields sides and size > in > > the > > derived type Square. > > > > Check if you have a serializer declared for Square in your generated > > stub. > > > > public XxxxxStub(javax.xml.rpc.Service service) throws > > org.apache.axis.AxisFault { > > if (service == null) { > > super.service = new org.apache.axis.client.Service(); > > } else { > > super.service = service; > > } > > ... > > qName = new javax.xml.namespace.QName("...", "Square"); > > cachedSerQNames.add(qName); > > cls = xxx.Square.class; > > cachedSerClasses.add(cls); > > cachedSerFactories.add(beansf); > > cachedDeserFactories.add(beandf); > > .... > > } > > > > > > Then check with the tcpmonitor what was send back by the server. > > > > Christophe > > > > >