Hi Thomas,

I had same problem. I used ObjectServiceFactory instead of JaxbServiceFactory.

Regards,
Zdenek

On 4/22/07, Thomas Larsson <[EMAIL PROTECTED]> wrote:
Hello everyone,

I have seen some posts similar to this on the list but no one with a
satisfactory answer so here goes.

I'm trying to write a code-first example using jaxb 2.0 for the binding.
Im using spring remoting to export my service and just to be clear,
I am writing my payload classes, not generating them.
The server works ok and can be called with SOAPUI for example with the
response message as shown below.

My problem is that when I try to use the client created by the
XFireClientFactoryBean,
the unmarshalled response object is returned, but the property that it
contains is null.

Below are the relevant contents of my example web-app project.
I also attach a zipped copy of the eclipse project.

Here is the message returned from the server:
------------------------------------------------------------------------------------------------------------------------------
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance";>
<soap:Body>
<getNewObjectResponse xmlns="http://www.example.com";>
<ns2:ExampleObject xmlns:ns2=" http://www.example.com";>
<someList>
<someProperty>bulle-0</someProperty>
</someList>
</ns2:ExampleObject>
</getNewObjectResponse>
</soap:Body>
</soap:Envelope>

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

Here is the wsdl:
------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.example.com";
xmlns:tns=" http://www.example.com";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soapenc11="
http://schemas.xmlsoap.org/soap/encoding/";
xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding";
xmlns:soap11=" http://schemas.xmlsoap.org/soap/envelope/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
  <wsdl:types>
<xsd:schema xmlns:xsd=" http://www.w3.org/2001/XMLSchema";
attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace=" http://www.example.com";>
<xsd:element name="getNewObject">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="listSize" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getNewObjectResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="ExampleObject"
nillable="true" type="tns:exampleObject"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
targetNamespace=" http://www.example.com"; version="1.0">
<xs:complexType name="exampleObject">
<xs:sequence>
<xs:element xmlns:ns1=" http://www.example.com"; maxOccurs="unbounded"
minOccurs="0" name="someList" nillable="true" type="ns1:exampleListObject"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="exampleListObject">
<xs:sequence>
<xs:element minOccurs="0" name="someProperty" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="getNewObjectResponse">
    <wsdl:part name="parameters"
element="tns:getNewObjectResponse"/>
  </wsdl:message>
  <wsdl:message name="getNewObjectRequest">
    <wsdl:part name="parameters" element="tns:getNewObject"/>
  </wsdl:message>
  <wsdl:portType name="ExampleService">
    <wsdl:operation name="getNewObject">
      <wsdl:input name="getNewObjectRequest"
message="tns:getNewObjectRequest"/>
      <wsdl:output name="getNewObjectResponse"
message="tns:getNewObjectResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ExampleServiceHttpBinding"
type="tns:ExampleService">
    <wsdlsoap:binding style="document" transport="
http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getNewObject">
      <wsdlsoap:operation soapAction=""/>
       <wsdl:input name="getNewObjectRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getNewObjectResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ExampleService">
    <wsdl:port name="ExampleServiceHttpPort"
binding="tns:ExampleServiceHttpBinding">
      <wsdlsoap:address
location="http://localhost/services/ExampleService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
------------------------------------------------------------------------------------------------------------------------------

Here are my Service Interface and Implementation:

------------------------------------------------------------------------------------------------------------------------------
@WebService(name="ExampleService",
targetNamespace="http://www.example.com";)
public interface ExampleService {

    @WebMethod
    @WebResult(name="ExampleObject")
    public ExampleObject
getNewObject(@WebParam(name="listSize") int listSize);
}
------------------------------------------------------------------------------------------------------------------------------
@WebService(endpointInterface="example.ExampleService",
serviceName="ExampleService")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.BARE )
public class ExampleServiceImpl implements ExampleService{

    public ExampleObject getNewObject(int listSize) {

        ExampleObject object = new ExampleObject();
        List list = new ArrayList();
        for(int i=0;i<listSize;i++){
            ExampleListObject listObject = new ExampleListObject();
            listObject.setSomeProperty("dummy-"+String.valueOf(i));
            list.add(listObject);
        }
        object.setSomeList(list);

        return object;
    }
}
------------------------------------------------------------------------------------------------------------------------------

Here are my Payload objects ExampleObject and ExampleListObject:
------------------------------------------------------------------------------------------------------------------------------
@XmlAccessorType( XmlAccessType.FIELD)
@XmlType(name = "exampleObject", propOrder = { "someList" }, namespace =
"http://www.example.com";)
public class ExampleObject implements Serializable {

    @XmlElement(nillable = true)
    private List<ExampleListObject> someList;

    public List<ExampleListObject> getSomeList() {
        return someList;
    }

    public void setSomeList(List<ExampleListObject>
someList) {
        this.someList = someList;
    }
}
------------------------------------------------------------------------------------------------------------------------------
@XmlAccessorType(XmlAccessType.FIELD )
@XmlType(name = "exampleListObject", propOrder = { "someProperty" },
namespace = "http://www.example.com";)
public class ExampleListObject implements Serializable {

    @XmlElement
    private String someProperty;

    public String getSomeProperty() {
        return someProperty;
    }

    public void setSomeProperty(String someProperty) {
        this.someProperty = someProperty;
    }

}
------------------------------------------------------------------------------------------------------------------------------

xfire-servlet.xml:
------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd ">

<beans>

    <import
resource="classpath:org/codehaus/xfire/spring/xfire.xml"
/>

    <bean

class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
">
        <property name="urlMap">
            <map>
                <entry key="/ExampleService">
                    <ref bean="exampleService" />
                </entry>
            </map>
        </property>
    </bean>

    <bean id="exampleService"

class="org.codehaus.xfire.spring.remoting.XFireExporter ">
        <property name="serviceFactory">
            <bean
class="org.codehaus.xfire.jaxb2.JaxbServiceFactory"/>
        </property>
        <property name="xfire">
            <ref bean="xfire" />
        </property>
        <property name="serviceBean">
            <ref bean="exampleServiceImpl" />
        </property>
        <property name="serviceClass">
            <value>example.ExampleService</value>
        </property>
    </bean>

    <bean id="exampleServiceImpl" class=" example.ExampleServiceImpl" />
</beans>
------------------------------------------------------------------------------------------------------------------------------

The client and client context files:

------------------------------------------------------------------------------------------------------------------------------
public class ExampleServiceClient {

    public static final String CLIENT_CONTEXT_CONFIG_LOCATION =
"example/clientContext.xml";

    private static Log log = LogFactory.getLog(ExampleServiceClient.class);

    private final ListableBeanFactory beanFactory;

    public ExampleServiceClient(ListableBeanFactory
factory) {
        beanFactory = factory;
    }

    public void invokeService() {
        Map orderServices = this.beanFactory
                .getBeansOfType(ExampleService.class);
        for (Iterator it = orderServices.keySet().iterator(); it.hasNext();)
{
            String beanName = (String) it.next();
            ExampleService service = (ExampleService) orderServices
                    .get(beanName);

            log.debug("Calling ExampleService '" + beanName + "'");
            ExampleObject results = service.getNewObject(1);
            if( results!=null){
                log.debug("done");
                if(results.getSomeList()!=null) System.out.println("Good!
List is not null");
                else
                    log.debug("Bad! List is null.");
            }else{
                log.debug("failed");
            }
        }
    }

    public static void main(String[] args) {
        log.debug("Starting client.");
        ListableBeanFactory beanFactory = new
ClassPathXmlApplicationContext(
                CLIENT_CONTEXT_CONFIG_LOCATION);
        ExampleServiceClient client = new
ExampleServiceClient(beanFactory);
        client.invokeService();

    }
}
------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd";>

<beans>

    <!-- XFire client proxy -->
    <bean id="xfireProxy"

class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
        <property name="serviceClass">
            <value>example.ExampleService</value>
        </property>
        <property name="wsdlDocumentUrl">
            <value>

http://localhost:8080/bug/xfire/ExampleService?wsdl
            </value>
        </property>
        <property name="serviceFactory">
            <bean
class="org.codehaus.xfire.jaxb2.JaxbServiceFactory " />
        </property>
        <property name="url"

value="http://localhost:8080/bug/xfire/ExampleService " />
        <property name="properties">
            <map>
                <entry key="objectServiceFactory.style">
                    <value>document</value>
                </entry>
                <entry key="objectServiceFactory.use">
                    <value>literal</value>
                </entry>
            </map>
        </property>
        <property name="inHandlers">
            <list>
                <bean
class="org.codehaus.xfire.util.dom.DOMInHandler" />
                <bean class="
org.codehaus.xfire.util.LoggingHandler" />
            </list>
        </property>
    </bean>
</beans>

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


Your help is greatly appreciated.
-Thomas


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to