Hi,

I have created an xfire web service by crafting a wsdl with an
imported schema using a tool, generated pojo's, and created a server.
The service works fine if I create a client based on the client code
from xfire, but when I try to use the service from testing tools like
SOAPscope or SoapUi, the tests fail.  But, seeing that an XFire based
client succeeds, I can modifya request to enclose parameters in
<in0>...</in0>, and the test succeeds.
It seems like the xfire service requires the method parameters to be
put into an array, but the test tools interpretation of the wsdl and
schema does not think so. How can that be?

I have seen similar cases in the mailing lists and Jira, but not much
examples or conclusions. But maybe I missed something obvious?

So I made an experiment and created a contrived dummy service from
scratch to be able to show the case:

Below are:
1. test.wsdl
2. test.xsd
3: Script to generate code:
4. ServiceStarter.java
5. Request from test tool + (failing) result
6. Hand edited request + (successful) result

1. test.wsdl:
=========
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Test"
targetNamespace="http://www.example.org/test/definitions";
xmlns:tns="http://www.example.org/test/definitions";
xmlns:types="http://www.example.org/test/schemas";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>

<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://www.example.org/test/schemas";>
<xsd:import namespace="http://www.example.org/test/schemas";
schemaLocation="test.xsd" />
</xsd:schema>
</wsdl:types>

<wsdl:message name="favoriteColorInput">
<wsdl:part element="types:favoriteColor" name="parameters" />
</wsdl:message>
<wsdl:message name="favoriteColorOutput">
<wsdl:part element="types:favoriteColorResponse" name="parameters" />
</wsdl:message>

<wsdl:portType name="Test">
<wsdl:operation name="favoriteColor">
<wsdl:input message="tns:favoriteColorInput" name="favoriteColorInput" />
<wsdl:output message="tns:favoriteColorOutput" name="favoriteColorOutput" />
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="testSOAP" type="tns:Test">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"; />
<wsdl:operation name="favoriteColor">
<soap:operation soapAction="" />
<wsdl:input><soap:body use="literal" /></wsdl:input>
<wsdl:output><soap:body use="literal" /></wsdl:output>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="Test">
<wsdl:port binding="tns:testSOAP" name="testSOAP">
<soap:address location="http://localhost:8191/Test"; />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

2. test.xsd
========
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://www.example.org/test/schemas";
elementFormDefault="qualified">
<xsd:element name="favoriteColor">
    <xsd:complexType>
        <xsd:all>
              <xsd:element name="Person" type="xsd:string" />
              <xsd:element name="Day" type="xsd:string" />
        </xsd:all>
     </xsd:complexType>
</xsd:element>
<xsd:element name="favoriteColorResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="Code" type="xsd:integer" />
            <xsd:element name="Message" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
</xsd:schema>

3: Script to generate code:
===================
#!/bin/bash

WSDL="../WSTest/test.wsdl"

export 
gpath="xfire-all-1.2.2.jar;lib/XmlSchema-1.1.jar;lib/activation-1.1.jar;lib/ant-1.5.jar;lib/bcprov-jdk15-133.jar;lib/common
s-attributes-api-2.1.jar;lib/commons-beanutils-1.7.0.jar;lib/commons-codec-1.3.jar;lib/commons-discovery-0.2.jar;lib/commons-httpc
lient-3.0.jar;lib/commons-logging-1.0.4.jar;lib/jaxb-api-2.0.jar;lib/jaxb-impl-2.0.1.jar;lib/jaxb-xjc-2.0.1.jar;lib/jaxen-1.1-beta
-9.jar;lib/jaxws-api-2.0.jar;lib/jdom-1.0.jar;lib/jmock-1.0.1.jar;lib/jsr173_api-1.0.jar;lib/junit-3.8.1.jar;lib/mail-1.4.jar;lib/
opensaml-1.0.1.jar;lib/org.mortbay.jetty-5.1.3.jar;lib/saaj-api-1.3.jar;lib/saaj-impl-1.3.jar;lib/servlet-api-2.3.jar;lib/spring-1
.2.6.jar;lib/stax-api-1.0.1.jar;lib/stax-utils-snapshot-20040917.jar;lib/wsdl4j-1.5.2.jar;lib/wss4j-1.5.0.jar;lib/wstx-asl-3.0.1.j
ar;lib/xbean-2.1.0.jar;lib/xbean-spring-2.5.jar;lib/xercesImpl-2.6.2.jar;lib/xfire-jsr181-api-1.0-M1.jar;lib/xml-apis-1.0.b2.jar;l
ib/xmlsec-1.3.0.jar;lib/*.zip"

java -cp $gpath org.codehaus.xfire.gen.WsGen -wsdl $WSDL -o
../WSTest/source/java -p org.example.ws.stub -overwrite true

4: ServiceStarter.java
===============
package org.example.ws.server;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.server.http.XFireHttpServer;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.service.invoker.BeanInvoker;
import org.example.ws.stub.Test;
import org.example.ws.stub.TestImpl;
public class ServiceStarter
{
XFireHttpServer server;

public void start() throws Exception
{
// Create a service
ObjectServiceFactory serviceFactory = new ObjectServiceFactory();

//Create an XFire Service
Service service = serviceFactory.create(Test.class);
service.setInvoker(new BeanInvoker(new TestImpl()));

// Register the service in the ServiceRegistry
XFire xfire = XFireFactory.newInstance().getXFire();
xfire.getServiceRegistry().register(service);

// Start the HTTP server
server = new XFireHttpServer();
server.setPort(8191);
server.start();

}
public static void main(String[] args)
{
ServiceStarter s = new ServiceStarter();
try  {  s.start();   }
catch (Exception e)
{   e.printStackTrace();   }
}
}

5. Request from test tool + (failing) result
==============================
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
<soapenv:Body>
  <s0:favoriteColor
      xmlns:s0="http://www.example.org/test/schemas";
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xmlns:xs="http://www.w3.org/2001/XMLSchema";>
     <s0:Person>Carl</s0:Person>
     <s0:Day>Monday</s0:Day>
  </s0:favoriteColor>
</soapenv:Body>
</soapenv:Envelope>

(failing) result:
<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>
  <soap:Fault>
     <faultcode>soap:Server</faultcode>
     <faultstring>Index: 1, Size: 1</faultstring>
  </soap:Fault>
</soap:Body>
</soap:Envelope>


6. Hand edited request + (successful) result
================================
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
<soapenv:Body>
  <s0:favoriteColor
      xmlns:s0="http://www.example.org/test/schemas";
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
     <in0>
        <s0:Person>Carl</s0:Person>
        <s0:Day>Monday</s0:Day>
     </in0>
  </s0:favoriteColor>
</soapenv:Body>
</soapenv:Envelope>

Succesful result - (UnsupportedOperationException is OK because I haven't
changed the stubs yet):
<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>
  <soap:Fault>
     <faultcode>soap:Client</faultcode>
     <faultstring>Fault:
java.lang.UnsupportedOperationException</faultstring>
  </soap:Fault>
</soap:Body>
</soap:Envelope>


Best regards,
Rickard

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

   http://xircles.codehaus.org/manage_email

Reply via email to