The "standard" pattern for bean usage is to use the default constructor and set any properties with mutator (setter) methods. To use the BeanSerializer with your MyDouble class, MyDouble must have a "double" property that is read/write, i.e. it either has public getter/setter methods or the field is public.
Scott Nichol ----- Original Message ----- From: "Serafina Sumargo" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 21, 2002 11:35 AM Subject: Need help with user defined Objects > I am a newbie and I have been trying to figure out a problem with one of > my code, hope you guys can help me out. > > Ok, so I have a MyDouble class that has a single double attribute. > Constructors: MyDouble() -> sets the double to 0 > MyDouble(double) > > Then I have a server calculator that does: > String add(MyDouble, MyDouble), taking 2 MyDoubles and returns a String > > Here is what I have with my client: > MyDouble num1 = new MyDouble(3.5); > MyDouble num2 = new MyDouble(2.6); > SOAPMappingRegistry smr = new SOAPMappingRegistry(); BeanSerializer bsr > = new BeanSerializer(); > smr.mapTypes("http://schemas.xmlsoap.org/soap/encoding/",new > QName("urn:calculatorService-mydouble", "num1"), MyDouble.class, bsr, > bsr); smr.mapTypes("http://schemas.xmlsoap.org/soap/encoding/",new > QName("urn:calculatorService-mydouble", "num2"), MyDouble.class, bsr, > bsr); > > Vector params = new Vector(); > params.addElement(new Parameter("num1", MyDouble.class, num1, null)); > params.addElement(new Parameter("num2", MyDouble.class, num2, null)); > > Call call = new Call(); > call.setTargetObjectURI("urn:calculatorService"); > call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/"); > call.setSOAPMappingRegistry(smr); > call.setParams(params); > > My Descriptor: > <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" > id="urn:calculatorService"> > <isd:provider type="java" scope="Application" methods="add sub mult > div"> > <isd:java class="Calculator" static="false"/> > </isd:provider> > > <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultLis > tener> > > <isd:mappings> > <isd:map > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > xmlns:x="urn:calculatorService-mydouble" qname="x:num1" > javaType="MyDouble" > > java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer" > > xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/> > <isd:map > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > xmlns:x="urn:calculatorService-mydouble" qname="x:num2" > javaType="MyDouble" > > java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer" > > xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/> > </isd:mappings> > </isd:service> > > The problem is, for some reason, it doesn't pass in the values num1 and > num2, instead it instantiates the default constructor of MyDouble, hence > always returning num1+num2 = 0. > > What did I do wrong? > > Serafina > > > > -- > To unsubscribe, e-mail: <mailto:soap-user-unsubscribe@;xml.apache.org> > For additional commands, e-mail: <mailto:soap-user-help@;xml.apache.org> > > -- To unsubscribe, e-mail: <mailto:soap-user-unsubscribe@;xml.apache.org> For additional commands, e-mail: <mailto:soap-user-help@;xml.apache.org>