You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Csaba Nemeth <cs...@yahoo.ca> on 2012/03/07 17:16:54 UTC

invalid outbound message content

Hi,

I am connecting to a .NET webservice using CXF. I have generated the clients
using the wsd2ljava ant task. It works well for calling service methods to
get objects, but calling service method and passing an object with list of
objects does not work.

The outbound message is not formatted according to the schema. 

On .NET side I have this DTO (similar to this):

class UserRole {
  public IList<int> IntList {set; get;}
  public IList<Range> RangeList {set; get; }
}

class Range {
  public int Index {get; set;}
  public decimal Minimum {get; set;}
  public decimal Rate { get; set; }
  public int RangeType { get; set; }
}

The wsdl2java generates these java classes:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserRole",
namespace="http://schemas.datacontract.org/2004/07/DTO", propOrder={
  "intList",
  "rangeList"
})
class UserRole {
  @XmlElementRef(name = "IntList", namespace="...", type=JAXBElement.class,
required=false)
  protected JAXBElement<ArrayOfint> intList;
  @XmlElementRef(name = "RangeList", namespace="...",
type=JAXBElement.class, required=false)
  protected JAXBElement<ArrayOfRange> rangeList;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfint", namespace =
"http://schemas.microsoft.com/2003/10/Serialization/Arrays", propOrder = {
    "_int"
})
class ArrayOfint {
  @XmlElement(name = "int", type = Integer.class)
    protected List<Integer> _int;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfRange", namespace =
"http://schemas.datacontract.org/2004/07/DTO", propOrder = {
    "range"
})
class ArrayOfRange {
    @XmlElement(name = "Range", nillable = true)
    protected List<Range> range;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Range", namespace =
"http://schemas.datacontract.org/2004/07/DTO", propOrder = {
    "minimum",
    "index",
    "rate",
    "rangeType"
})
class Range {
    @XmlElement(name = "Minimum")
    protected BigDecimal minimum;
    @XmlElement(name = "Index")
    protected Integer index;
    @XmlElement(name = "Rate")
    protected BigDecimal rate;
    @XmlElement(name = "RangeType")
    protected Integer rangeType;
}


When I construct an object with ObjectFactory to of UserRole to pass it from
java to the .net side. The outbound message looks like this:

<ParamUserRole>
  <ns4:IntList>
     <ns3:int>1</ns3:int>
     <ns3:int>2</ns3:int>
  <ns4:IntList>
  <ns4:ArrayOfRange>
     <ns4:Range>
        <ns4:Minimum>1.00</ns4:Minimum>
        <ns4:Rate>1.00</ns4:Rate>
        <ns4:Index>1</ns4:Index>
        <ns4:RangeType>1</ns4:RangeType>
     </ns4:Range>
  </ns4:ArrayOfRange>
</ParamUserRole>


Although the message should look like this:


<ParamUserRole>
  <ns4:IntList>
     <ns3:int>1</ns3:int>
     <ns3:int>2</ns3:int>
  <ns4:IntList>
  <ns4:RangeList>
     <ns4:Range>
        <ns4:Minimum>1.00</ns4:Minimum>
        <ns4:Rate>1.00</ns4:Rate>
        <ns4:Index>1</ns4:Index>
        <ns4:RangeType>1</ns4:RangeType>
     </ns4:Range>
  </ns4:RangeList>
</ParamUserRole>


As you can see instead of ns4:RangeList the message contains
ns4:ArrayOfRange element.

I have tried with version 2.4.5 and 2.5.2.

Is there something I am missing during the wsdl2java call?
It seems to me the classes were defined with the proper names and field
names, yet the outbound message does not follow the schema.

Thank you,
Csaba

--
View this message in context: http://cxf.547215.n5.nabble.com/invalid-outbound-message-content-tp5544605p5544605.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: invalid outbound message content

Posted by Csaba Nemeth <cs...@yahoo.ca>.
Thank you, it worked as you suggested.
I somehow missed that ObjectFactory method.

I did use the object factory, but in the following way:

ArrayOfRange ranges = objectFactory.createArrayOfRange();
ranges.getRange().add(rangeObject);
userRole.setRangeList(objectFactory.createArrayOfRange(ranges));

I guess the types match up, but the jaxb mappings cannot be enforced.

I changed it to this:

userRole.setRangeList(objectFactory.createUserRoleRangeList(ranges));

It works as expected.

Thanks again, I should have looked at the object factory more careful.
 
--
Csaba


--
View this message in context: http://cxf.547215.n5.nabble.com/invalid-outbound-message-content-tp5544605p5545322.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: invalid outbound message content

Posted by Daniel Kulp <dk...@apache.org>.

How are you creating the JAXBElement for the RangeList field?   The QName 
being output there is whatever QName you are using for that JAXBElement.   
Most likely, look into the ObjectFactory and see what methods are there for 
constructing the JAXBElement.


Dan

On Wednesday, March 07, 2012 08:16:54 AM Csaba Nemeth wrote:
> Hi,
> 
> I am connecting to a .NET webservice using CXF. I have generated the
> clients using the wsd2ljava ant task. It works well for calling service
> methods to get objects, but calling service method and passing an object
> with list of objects does not work.
> 
> The outbound message is not formatted according to the schema.
> 
> On .NET side I have this DTO (similar to this):
> 
> class UserRole {
>   public IList<int> IntList {set; get;}
>   public IList<Range> RangeList {set; get; }
> }
> 
> class Range {
>   public int Index {get; set;}
>   public decimal Minimum {get; set;}
>   public decimal Rate { get; set; }
>   public int RangeType { get; set; }
> }
> 
> The wsdl2java generates these java classes:
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "UserRole",
> namespace="http://schemas.datacontract.org/2004/07/DTO", propOrder={
>   "intList",
>   "rangeList"
> })
> class UserRole {
>   @XmlElementRef(name = "IntList", namespace="...",
> type=JAXBElement.class, required=false)
>   protected JAXBElement<ArrayOfint> intList;
>   @XmlElementRef(name = "RangeList", namespace="...",
> type=JAXBElement.class, required=false)
>   protected JAXBElement<ArrayOfRange> rangeList;
> }
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "ArrayOfint", namespace =
> "http://schemas.microsoft.com/2003/10/Serialization/Arrays", propOrder = {
> "_int"
> })
> class ArrayOfint {
>   @XmlElement(name = "int", type = Integer.class)
>     protected List<Integer> _int;
> }
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "ArrayOfRange", namespace =
> "http://schemas.datacontract.org/2004/07/DTO", propOrder = {
>     "range"
> })
> class ArrayOfRange {
>     @XmlElement(name = "Range", nillable = true)
>     protected List<Range> range;
> }
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Range", namespace =
> "http://schemas.datacontract.org/2004/07/DTO", propOrder = {
>     "minimum",
>     "index",
>     "rate",
>     "rangeType"
> })
> class Range {
>     @XmlElement(name = "Minimum")
>     protected BigDecimal minimum;
>     @XmlElement(name = "Index")
>     protected Integer index;
>     @XmlElement(name = "Rate")
>     protected BigDecimal rate;
>     @XmlElement(name = "RangeType")
>     protected Integer rangeType;
> }
> 
> 
> When I construct an object with ObjectFactory to of UserRole to pass it
> from java to the .net side. The outbound message looks like this:
> 
> <ParamUserRole>
>   <ns4:IntList>
>      <ns3:int>1</ns3:int>
>      <ns3:int>2</ns3:int>
>   <ns4:IntList>
>   <ns4:ArrayOfRange>
>      <ns4:Range>
>         <ns4:Minimum>1.00</ns4:Minimum>
>         <ns4:Rate>1.00</ns4:Rate>
>         <ns4:Index>1</ns4:Index>
>         <ns4:RangeType>1</ns4:RangeType>
>      </ns4:Range>
>   </ns4:ArrayOfRange>
> </ParamUserRole>
> 
> 
> Although the message should look like this:
> 
> 
> <ParamUserRole>
>   <ns4:IntList>
>      <ns3:int>1</ns3:int>
>      <ns3:int>2</ns3:int>
>   <ns4:IntList>
>   <ns4:RangeList>
>      <ns4:Range>
>         <ns4:Minimum>1.00</ns4:Minimum>
>         <ns4:Rate>1.00</ns4:Rate>
>         <ns4:Index>1</ns4:Index>
>         <ns4:RangeType>1</ns4:RangeType>
>      </ns4:Range>
>   </ns4:RangeList>
> </ParamUserRole>
> 
> 
> As you can see instead of ns4:RangeList the message contains
> ns4:ArrayOfRange element.
> 
> I have tried with version 2.4.5 and 2.5.2.
> 
> Is there something I am missing during the wsdl2java call?
> It seems to me the classes were defined with the proper names and field
> names, yet the outbound message does not follow the schema.
> 
> Thank you,
> Csaba
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/invalid-outbound-message-content-tp554460
> 5p5544605.html Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com