It all has to do with how you want your XML formatted. As you saw before, 
using type="box:BoxType" does actually work, but you don't get the 
<BoxType/> wrapper element under <BoxOperation/>. You're defining 
<BoxOperation/> to be a type that is just a sequence of elements (width 
and height), and since we interpret each element under the operation 
element to be a parameter, you need two Java parameters (int width, int 
height).

If you want that extra wrapper element in there (<BoxType/>), then 
<BoxOperation/> has to be a sequence of elements. In this case, BoxType is 
the only element in the sequence. I assume that the reason you want the 
<BoxType/> wrapper is the possibility of adding other parameters that are 
unrelated to BoxType in the future.

I believe Muse's interpretation of XSD is correct in this case, and it's 
really just a matter of whether you want the box data right under 
<BoxOperation/> or separated out under a wrapper.

Dan



"Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 10/31/2006 
02:06:40 PM:

> Thanks Dan,
> I think I was defining the xml schema incorrectly in the wsdl.
> 
> So if I wanted to pass a single string parameter, I can define the
> schema as:
> <xsd:element name="BoxOperation" type="xsd:string"/>
> 
> But, if I wanted to pass a single complex-type parameter, I cannot
> define the schema as:
> <xsd:element name="BoxOperation" type="box:BoxType"/>
> 
> Instead, I must define it as:
> <xsd:element name="BoxOperation">
>   <xsd:complexType>
>     <xsd:sequence>
>       <xsd:element name="Box" type="box:BoxType"/>
>     </xsd:sequence>
>   </xsd:complexType>
> </xsd:element>
> 
> Then, my java code can look like:
> Element boxOperation(Element boxXML);
> 
> Is this correct?  Is there a reason why the single line schema form
> above won't work when trying to pass a single complex-type parameter?
> -Vinh
> 
> 
> -----Original Message-----
> From: Daniel Jemiolo [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 31, 2006 7:27 AM
> To: [email protected]
> Subject: Re: non-anonymous complex type
> 
> It's expecting "width" and "height" as the two parameters. If you want
> there to be one paramter ("width" and "height" wrapped in a "BoxType" 
> element"), try this:
> 
> <xsd:element name="BoxOperation">
>   <xsd:complexType>
>     <xsd:sequence>
>       <xsd:element name="Box" type="box:BoxType"/>
>     </xsd:sequence>
>   </xsd:complexType>
> </xsd:element>
> 
> What you have now requires that the SOAP look like this:
> 
> <BoxOperation>
>   <width>100</width>
>   <height>300</height>
> </BoxOperation>
> 
> and the Java like this:
> 
>         Box boxOperation(int width, int height);  // return Box or
> Element
> 
> 
> What you want is this (I think):
> 
> <BoxOperation>
>   <Box>
>     <width>100</width>
>     <height>300</height>
>   </Box>
> </BoxOperation>
> 
> 
> which translates to the XSD above and this Java:
> 
>         Box boxOperation(Box box);
> 
>         (or: Element boxOperation(Element boxXML);
> 
> 
> If you make a Serializer for Box objects, you can use Box in your
> methods instead of DOM Elements. See the last section of this page:
> 
> 
> http://ws.apache.org/muse/docs/2.0.0/manual/architecture/deployment-desc
> riptor.html#serializer
> 
> 
> 
> 
> 
> "Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 10/31/2006
> 02:41:18 AM:
> 
> > Hi all,
> > I'm trying to define a non-anonymous, custom complex type so that I 
> > can
> pass 
> > it as a single request parameter. But, I am running into some
> problems. 
> My 
> > custom type is defined as:
> >         <xsd:schema
> >             elementFormDefault="qualified"
> >             targetNamespace="http://cisco.com/muse/demo/cap/box";>
> >             <xsd:complexType name="BoxType">
> >                 <xsd:sequence>
> >                     <xsd:element name="width" type="xsd:integer"/>
> >                     <xsd:element name="height" type="xsd:integer"/>
> >                 </xsd:sequence>
> >             </xsd:complexType>
> >             <xsd:element name="BoxOperation" type="box:BoxType" />
> >             <xsd:element name="BoxOperationResponse"
> type="box:BoxType" 
> />
> >         </xsd:schema>
> > 
> > The java code for my operation is:
> >     public Element boxOperation(Element param1) throws Exception
> >     {
> >      BoxOperationDocument doc =
> BoxOperationDocument.Factory.parse(param1.
> > getParentNode());
> >      BoxType type = doc.getBoxOperation();
> >      type.setWidth(type.getWidth().add(BigInteger.valueOf(100)));
> >      type.setHeight(type.getHeight().add(BigInteger.valueOf(100)));
> >      return XmlUtils.getFirstElement(doc.getDomNode()); 
> >     }
> > 
> > The client code is:
> >     public String testBoxOperation()
> >     throws SoapFault
> >     {
> >      BoxOperationDocument doc =
> BoxOperationDocument.Factory.newInstance();
> >      BoxType box = doc.addNewBoxOperation();
> >      box.setWidth(BigInteger.valueOf(555));
> >      box.setHeight(BigInteger.valueOf(555));
> >      Element param1 = XmlUtils.getFirstElement(doc.getDomNode());
> > 
> >      Element body = XmlUtils.createElement(IBoxCapability.OP_QNAME,
> param1);
> >      Element response = invoke(IBoxCapability.OP_URI, body);
> >      return XmlUtils.extractText(response);
> >     }
> > 
> > I am expecting to pass a single object in the request, but I am 
> > getting
> an 
> > error indicating that two parameters are expected, not one.  Attached 
> > is
> the 
> > stack trace.  Can anyone tell me what I'm doing wrong?
> > -Vinh
> >  [attachment "ErrorTrace.txt" deleted by Daniel Jemiolo/Durham/IBM]
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to