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 Jose Luis Alba <jo...@yahoo.es> on 2007/07/20 15:10:19 UTC

Re: Unexpected subelement error using useOriginalWsdl in Axis2: Solution

HI all,

I've found a solution. When one uses useOriginalWsdl the package to namespace mappings are read from the services.xml file (see ServiceBuilder.java method processTypeMappings). The problem is when classes are out of the target namespace. All we have to do is to write the mappings in the services.xml file.

In my case there are:

<packageMapping>
    <mapping packageName="dev.axis2.ws.data" qName="http://data.ws.axis2.dev/xsd"/>
</packageMapping>

Salutations,

Jose


Jorge Fernandez <in...@yahoo.es> escribió: Hola Jose,

I usually have those problems when using rampart but only with classes that extend from others.

Regards,

Jorge Fernández


Jose Luis Alba <jo...@yahoo.es> escribió: Hi Mike,

The InputData and OutputData are simple JavaBean classes as:

package dev.axis2.ws.data;

public class InputData {
    private String data;

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
}

Recently I've tried with the last snapshot and with the Axis2 1.3 RC1 that Deepal proposed to me.

Now the SOAP response has changed  to:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:testDataResponse xmlns:ns="http://service.ws.axis2.dev">
      <ns:return type="dev.axis2.ws.data.OutputData">
        <ns:data>datos  de entrada</ns:data>
      </ns:return>
    </ns:testDataResponse>
  </soapenv:Body>
</soapenv:Envelope>

The solution is near but not sufficient. The return element that encloses the data element now has a type attribute but the client continues to launch an unexpected subelement exception due to incorrect namespace for data.

- I generated the clients in ADB mode.

Any more ideas? I will continue investigating..

Thanks all

Jose

Mike Patton <m_...@yahoo.com>  escribió: Jose,
   
  Does your OutputData class extend a java collection object or similar data type? If so, then this is why you are getting such an error. You should return a single element; even if you have an array or so to  return, wrap that in a property of another class and return that other type instead.
  Hope that helps.
   
  Mike
   
   
   
   
   
   
  

Jose Luis Alba <jo...@yahoo.es> wrote:
  Hi,

-  I'm using Axis2 1.2

I've create a POJO  test web service that resides in package dev.axis2.ws.service and uses in/out bean data from package dev.axis2.ws.data. 

The  interface is:

package dev.axis2.ws.service;

import dev.axis2.ws.data.InputData;
import dev.axis2.ws.data.OutputData;

public interface TestService {
    public OutputData testData(InputData input);
}

1) When I use automatic wsdl generation from Axis (in the services.xml file) all goes well. Here is the SOAP response of the execution:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:testDataResponse  xmlns:ns="http://service.ws.axis2.dev/xsd">
      <ns:return>
        <data  xmlns="http://data.ws.axis2.dev/xsd">datos de entrada</data>
          </ns:return>
      </ns:testDataResponse>
   </soapenv:Body>
</soapenv:Envelope>

2) Things goes wrong when I use the parameter useOriginalWsdl in the services.xml file. Here the services.xml file:

<service name="TestService">
  <messageReceivers>
    <messageReceiver
      mep="http://www.w3.org/2004/08/wsdl/in-only"
      class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
    <messageReceiver
       mep="http://www.w3.org/2004/08/wsdl/in-out"
      class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
  </messageReceivers>
  <parameter  locked="false" name="ServiceClass">dev.axis2.ws.service.TestServiceImpl</parameter>
  <parameter locked="false" name="useOriginalwsdl">true</parameter>
  <parameter locked="false"  name="modifyUserWSDLPortAddress">true</parameter>
</service>

The SOAP response I receive in the client side is:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:testDataResponse xmlns:ns="http://service.ws.axis2.dev/xsd">
      <ns:return>
        <ns:data>datos de entrada</ns:data>
       </ns:return>
    </ns:testDataResponse>
  </soapenv:Body>
</soapenv:Envelope>

In this case the namespace for the data element (it should map to http://data.ws.axis2.dev/xsd)  is missing and the client throws and Unexpected subelement exception.

I have tried:

- Axis2 1.2
- Axis2 1.1.1
- Axis2 last snapshot
- Using the wsdl  generated automatically
- Using the wsld generated by axis2 tools (ant task and by command line)

In all cases the behavior is the same: Unexpeted subelement and the missing namespace in the response message.

Could you help me please? Thanks in advance!

Jose Luis


    
---------------------------------
  
Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .


        

---------------------------------
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.  
          

---------------------------------

Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .

          

---------------------------------

Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .


       
---------------------------------

Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!.