You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ben Reif <Be...@cgi-ams.com> on 2005/12/06 15:05:16 UTC

Urgent Array issue - Incorrect DOC/LIT SOAP request from client?

I'm trying to create a DOC/LIT style service that uses an object that
contains getters and setters for a List of objects.
The List contains RequestFormItemizedLine objects. The containing
object, ItemizedRequestForm, looks like:
 
public class ItemizedRequestForm{
        public List getItemizedLines()
        public void setItemizedLines(List)
}
 
Anyway, I run the java2wsdl and get this in my WSDL:
 
<complexType name="ItemizedRequestForm">
 <sequence>
    ....
      <element maxOccurs="1" minOccurs="0" name="itemizedLines"
nillable="true" type="impl:ArrayOf_tns1_RequestFormItemizedLine" /> 
    ....
 </sequence>
</complexType    
 
 

<complexType name="ArrayOf_tns1_RequestFormItemizedLine">
 <sequence>
  <element maxOccurs="unbounded" minOccurs="0" name="item"
type="tns1:RequestFormItemizedLine" /> 
 </sequence>
</complexType>
 
<complexType name="RequestFormItemizedLine">
 <sequence>
        ....
 </sequence>
</complexType>
 

Then I run wsdl2java (have tried both wrapArrays=true/false) to generate
the client stubs, and at runtime I get a SOAP request that looks like:
 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> ">
  <soapenv:Body>
    <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com
<http://form.pe.domain.momentum.ams.com> ">
        .....
      <itemizedLines>
        <ns1:item
xmlns:ns1="http://MomentumWebServices/service/ItemizedRequestFormService
<http://MomentumWebServices/service/ItemizedRequestFormService> ">
                .....
        </item>
      </itemizedLines>
    </ItemizedRequestForm4>
    .....
  </Body>
</Envelope>
    
 
When the SOAP message is being processed on the server this results in
an exception:
 
org.xml.sax.SAXException: SimpleDeserializer encountered a child
element, which is NOT expected, in something it was trying to
deserialize.
 

My first question has to do with the WSDL, why does it automatically use
the name "item" when it's not a valid field in the object?  My second
question
is in the generated stubs, why does is assume the target namespace for
item? This is incorrect since it doesn't corespond  to any object in
that namespace, 
and it seem like on the server it can't find the deserializer for that
combination and defaults to the SimpleDeserializer, which throws the
error.
Shouldn't the SOAP request really look something like (assuming there
were 3 RequestFormItemizedLine objects in the List):
 

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> ">
  <soapenv:Body>
    <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com
<http://form.pe.domain.momentum.ams.com> ">
        .....
      <itemizedLines
xmlns="http://MomentumWebServices/service/ItemizedRequestFormService
<http://MomentumWebServices/service/ItemizedRequestFormService> ">
        <ns1:RequestFormItemizedLine
xmlns:ns1="http://form.pe.domain.momentum.ams.com
<http://form.pe.domain.momentum.ams.com> ">
                .....
        </RequestFormItemizedLine>
        <ns1:RequestFormItemizedLine
xmlns:ns1="http://form.pe.domain.momentum.ams.com
<http://form.pe.domain.momentum.ams.com> ">
                .....
        </RequestFormItemizedLine>
        <ns1:RequestFormItemizedLine
xmlns:ns1="http://form.pe.domain.momentum.ams.com
<http://form.pe.domain.momentum.ams.com> ">
                .....
        </RequestFormItemizedLine>
      </itemizedLines>
    </ItemizedRequestForm4>
    .....
  </Body>
</Envelope>
 

Could someone please let me know if this is correct or not, and how to
get the client to send the SOAP request in the correct way?
 
-Thanks in advance
 
Ben
 
 

Re: Urgent Array issue - Incorrect DOC/LIT SOAP request from client?

Posted by iksrazal <ik...@gmail.com>.
Hi, 

Basically just posting your "SAXException: SimpleDeserializer encountered a 
child element, which is NOT expected, in something it was trying to  
deserialize"  message says it all. This is a very common problem, although 
when I ran into it the solution wasn't that easy. I suggest googling on that 
exception as there probably is some better advice out there. 

The way I solved it was using the jboss 4.0.2 support libs for axis. You need 
to set a mapping location, or be able to reference the mapping location 
somehow. 

 org.jboss.webservice.client.ServiceFactoryImpl factory= 
(org.jboss.webservice.client.ServiceFactoryImpl) 
ServiceFactoryImpl.newInstance();
            javax.xml.rpc.Service service = factory.createService(url, 
mappinglocation, ws4eeMetaData,  qname, null);
            endpoint = (CallCentreWebEndpoint) 
service.getPort(CallCentreWebEndpoint.class);

As I stated try googling on your exception. 

HTH,
iksrazal


Em Terça 06 Dezembro 2005 12:05, o Ben Reif escreveu:
> I'm trying to create a DOC/LIT style service that uses an object that
> contains getters and setters for a List of objects.
> The List contains RequestFormItemizedLine objects. The containing
> object, ItemizedRequestForm, looks like:
>
> public class ItemizedRequestForm{
>         public List getItemizedLines()
>         public void setItemizedLines(List)
> }
>
> Anyway, I run the java2wsdl and get this in my WSDL:
>
> <complexType name="ItemizedRequestForm">
>  <sequence>
>     ....
>       <element maxOccurs="1" minOccurs="0" name="itemizedLines"
> nillable="true" type="impl:ArrayOf_tns1_RequestFormItemizedLine" />
>     ....
>  </sequence>
> </complexType
>
>
>
> <complexType name="ArrayOf_tns1_RequestFormItemizedLine">
>  <sequence>
>   <element maxOccurs="unbounded" minOccurs="0" name="item"
> type="tns1:RequestFormItemizedLine" />
>  </sequence>
> </complexType>
>
> <complexType name="RequestFormItemizedLine">
>  <sequence>
>         ....
>  </sequence>
> </complexType>
>
>
> Then I run wsdl2java (have tried both wrapArrays=true/false) to generate
> the client stubs, and at runtime I get a SOAP request that looks like:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
> <http://schemas.xmlsoap.org/soap/envelope/> "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema
> <http://www.w3.org/2001/XMLSchema> "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> <http://www.w3.org/2001/XMLSchema-instance> ">
>   <soapenv:Body>
>     <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com
> <http://form.pe.domain.momentum.ams.com> ">
>         .....
>       <itemizedLines>
>         <ns1:item
> xmlns:ns1="http://MomentumWebServices/service/ItemizedRequestFormService
> <http://MomentumWebServices/service/ItemizedRequestFormService> ">
>                 .....
>         </item>
>       </itemizedLines>
>     </ItemizedRequestForm4>
>     .....
>   </Body>
> </Envelope>
>
>
> When the SOAP message is being processed on the server this results in
> an exception:
>
> org.xml.sax.SAXException: SimpleDeserializer encountered a child
> element, which is NOT expected, in something it was trying to
> deserialize.
>
>
> My first question has to do with the WSDL, why does it automatically use
> the name "item" when it's not a valid field in the object?  My second
> question
> is in the generated stubs, why does is assume the target namespace for
> item? This is incorrect since it doesn't corespond  to any object in
> that namespace,
> and it seem like on the server it can't find the deserializer for that
> combination and defaults to the SimpleDeserializer, which throws the
> error.
> Shouldn't the SOAP request really look something like (assuming there
> were 3 RequestFormItemizedLine objects in the List):
>
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
> <http://schemas.xmlsoap.org/soap/envelope/> "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema
> <http://www.w3.org/2001/XMLSchema> "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> <http://www.w3.org/2001/XMLSchema-instance> ">
>   <soapenv:Body>
>     <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com
> <http://form.pe.domain.momentum.ams.com> ">
>         .....
>       <itemizedLines
> xmlns="http://MomentumWebServices/service/ItemizedRequestFormService
> <http://MomentumWebServices/service/ItemizedRequestFormService> ">
>         <ns1:RequestFormItemizedLine
> xmlns:ns1="http://form.pe.domain.momentum.ams.com
> <http://form.pe.domain.momentum.ams.com> ">
>                 .....
>         </RequestFormItemizedLine>
>         <ns1:RequestFormItemizedLine
> xmlns:ns1="http://form.pe.domain.momentum.ams.com
> <http://form.pe.domain.momentum.ams.com> ">
>                 .....
>         </RequestFormItemizedLine>
>         <ns1:RequestFormItemizedLine
> xmlns:ns1="http://form.pe.domain.momentum.ams.com
> <http://form.pe.domain.momentum.ams.com> ">
>                 .....
>         </RequestFormItemizedLine>
>       </itemizedLines>
>     </ItemizedRequestForm4>
>     .....
>   </Body>
> </Envelope>
>
>
> Could someone please let me know if this is correct or not, and how to
> get the client to send the SOAP request in the correct way?
>
> -Thanks in advance
>
> Ben

Re: Urgent Array issue - Incorrect DOC/LIT SOAP request from client?

Posted by Jason Cwik <bi...@gmail.com>.
I've run into this problem too. (
http://marc.theaimsgroup.com/?l=axis-user&m=113336992622255&w=2) It seems
that whenever running WSDL2Java things appear correct, but the if you look
at the dynamic WSDL generated by Axis it renames message elements to
"item".  This only appears to happen when the message only includes one
unbounded element in its complex type.  The workaround that I used was to
add another element to the complex type; then axis seems to work fine.

On 12/6/05, Ben Reif <Be...@cgi-ams.com> wrote:
>
> I'm trying to create a DOC/LIT style service that uses an object that
> contains getters and setters for a List of objects.
> The List contains RequestFormItemizedLine objects. The containing object,
> ItemizedRequestForm, looks like:
>
> public class ItemizedRequestForm{
>         public List getItemizedLines()
>         public void setItemizedLines(List)
> }
>
> Anyway, I run the java2wsdl and get this in my WSDL:
>
> <complexType name="ItemizedRequestForm">
>  <sequence>
>     ....
>       <element maxOccurs="1" minOccurs="0" name="itemizedLines"
> nillable="true" type="impl:ArrayOf_tns1_RequestFormItemizedLine" />
>     ....
>  </sequence>
> </complexType
>
>
>
> <complexType name="ArrayOf_tns1_RequestFormItemizedLine">
>  <sequence>
>   <element maxOccurs="unbounded" minOccurs="0" name="item"
> type="tns1:RequestFormItemizedLine" />
>  </sequence>
> </complexType>
>
> <complexType name="RequestFormItemizedLine">
>  <sequence>
>         ....
>  </sequence>
> </complexType>
>
>
> Then I run wsdl2java (have tried both wrapArrays=true/false) to generate
> the client stubs, and at runtime I get a SOAP request that looks like:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance">
>   <soapenv:Body>
>     <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com">
>         .....
>       <itemizedLines>
>         <ns1:item xmlns:ns1="
> http://MomentumWebServices/service/ItemizedRequestFormService">
>                 .....
>         </item>
>       </itemizedLines>
>     </ItemizedRequestForm4>
>     .....
>   </Body>
> </Envelope>
>
>
> When the SOAP message is being processed on the server this results in an
> exception:
>
> org.xml.sax.SAXException: SimpleDeserializer encountered a child element,
> which is NOT expected, in something it was trying to deserialize.
>
>
> My first question has to do with the WSDL, why does it automatically use
> the name "item" when it's not a valid field in the object?  My second
> question
> is in the generated stubs, why does is assume the target namespace for
> item? This is incorrect since it doesn't corespond  to any object in that
> namespace,
> and it seem like on the server it can't find the deserializer for that
> combination and defaults to the SimpleDeserializer, which throws the error.
> Shouldn't the SOAP request really look something like (assuming there were
> 3 RequestFormItemizedLine objects in the List):
>
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance">
>   <soapenv:Body>
>     <ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com">
>         .....
>       <itemizedLines xmlns="
> http://MomentumWebServices/service/ItemizedRequestFormService">
>         <ns1:RequestFormItemizedLine xmlns:ns1="
> http://form.pe.domain.momentum.ams.com">
>                 .....
>         </RequestFormItemizedLine>
>         <ns1:RequestFormItemizedLine xmlns:ns1="
> http://form.pe.domain.momentum.ams.com">
>                 .....
>         </RequestFormItemizedLine>
>         <ns1:RequestFormItemizedLine xmlns:ns1="
> http://form.pe.domain.momentum.ams.com">
>                 .....
>         </RequestFormItemizedLine>
>       </itemizedLines>
>     </ItemizedRequestForm4>
>     .....
>   </Body>
> </Envelope>
>
>
> Could someone please let me know if this is correct or not, and how to get
> the client to send the SOAP request in the correct way?
>
> -Thanks in advance
>
> Ben
>
>
>