Dear,

I'm pretty new at webservices. I have some minor experience with AXIS, but wanted to try spring webservices in stead because it looks more straightforwarded to me. I use castor for my marshalling and unmarshalling and already have a little webservice running.

I now want to connect to a UNIFACE webservice (which uses RPC, not document literal), but I'm not able to unmarshall the response. I always get the message:
org.exolab.castor.xml.MarshalException: The namespace associated with the prefix 'xsi' could not be resolved.

Allthought, when I catch the response in my TCP monitor and paste it in a XML file (skipping the soap tags) and use the castor native API to read the xml I get no problem at all. I even don't have to define namespaces anywhere ...


Response I get from the webservice:

Code:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Date: Mon, 28 Jan 2008 09:10:33 GMT
Content-Type: text/xml;charset=UTF-8
Content-Length: 2917

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001XMLSchema" xmlns:xsi="http://www.w3.org/2001XMLSchema-instance" xmlns:tns="urn:uniface:applic:services:FACADES_XXX:SF_ACCOUNT" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:uniface:applic:services:CS_XXXACCOUNT" xmlns:ns2="urn:uniface:applic:services:XXXERROR"> 
      <soapenv:Body>  
         <tns:AANLOGGEN>   
            <return xsi:type="xsd:int">0</return>   
            <GENERATED_PARAMETER_NAME_2 xsi:type="soapenc:Array" soapenc:arrayType="ns1:CS_XXXACCOUNTType[1]">    
               <Item xsi:type="ns1:CS_XXXACCOUNTType">     
                  <CD xsi:type="xsd:string">Basisprofiel</CD>     
                  <NM xsi:type="xsd:string">Basisprofiel</NM>     
                  <IDSTD xsi:type="xsd:string">J</IDSTD>     
                  <IDSLG xsi:type="xsd:string">J</IDSLG>     
                  <IDAZEXP xsi:type="xsd:string">J</IDAZEXP>     
                  <IDCALC xsi:type="xsd:string">J</IDCALC>     
                  <IDBEST xsi:type="xsd:string">N</IDBEST>     
                  <IDBESTB xsi:type="xsd:string">N</IDBESTB>     
                  <IDBESTM xsi:type="xsd:string">N</IDBESTM>     
                  <IDADR xsi:type="xsd:string">N</IDADR>     
                  <IDHERINT xsi:type="xsd:string">N</IDHERINT>     
                  <IDHERCON xsi:type="xsd:string">N</IDHERCON>     
                  <DTLMUT xsi:type="xsd:dateTime">2004-02-03T09:56:50.00+01:00</DTLMUT>     
                  <NMLMUT xsi:type="xsd:string">XXX</NMLMUT>     
                  <RELATIENUMMER xsi:type="xsd:int">AAA</RELATIENUMMER>     
                  <CDADM xsi:type="xsd:string">AAA</CDADM>     
                  <MOEDERMIJNUMMER xsi:type="xsd:int">123</MOEDERMIJNUMMER>     
                  <RELATIENAAM xsi:type="xsd:string">XXX</RELATIENAAM>     
                  <OM_N xsi:type="xsd:string">Basisprofiel</OM_N>     
                  <OM_F xsi:type="xsd:string">Profil de base</OM_F>     
                  <OM_E xsi:type="xsd:string">Default profile</OM_E>     
                  <OM_D xsi:type="xsd:string">Basisprofiel</OM_D>     
                  <WPBNUMMER xsi:type="xsd:short">1</WPBNUMMER>     
                  <WPBNAAM xsi:type="xsd:string">XXX</WPBNAAM>     
                  <VOORNAAM xsi:type="xsd:string">XXX</VOORNAAM>     
                  <IDWPAOV xsi:type="xsd:string">N</IDWPAOV>     
                  <IDAROV xsi:type="xsd:string">N</IDAROV>     
                  <IDEXPRT xsi:type="xsd:string">N</IDEXPRT>     
                  <IDEXRES xsi:type="xsd:string">N</IDEXRES>     
                  <IDCONT xsi:type="xsd:string">N</IDCONT>     
                  <IDPROF xsi:type="xsd:string">J</IDPROF>     
                  <IDRELSPC xsi:type="xsd:string">N</IDRELSPC>     
                  <ACCOUNTID xsi:type="xsd:string">AAAAA</ACCOUNTID>     
                  <KLANTCATEGORIE xsi:type="xsd:string">G</KLANTCATEGORIE>     
                  <ATOBJSL xsi:type="xsd:short">5000</ATOBJSL>     
                  <ATMAXC xsi:type="xsd:short">50</ATMAXC>     
                  <BDMAXCP xsi:type="xsd:float">100000</BDMAXCP>     
                  <ATMNDCP xsi:type="xsd:short">60</ATMNDCP>    
               </Item>   
            </GENERATED_PARAMETER_NAME_2>   
            <GENERATED_PARAMETER_NAME_3 xsi:type="soapenc:Array" soapenc:arrayType="ns2:XXXERRORType[0]" xsi:nil="true"/>  
         </tns:AANLOGGEN> 
      </soapenv:Body>
   </soapenv:Envelope>
My Mapping file:

Code:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">
<mapping>


    <class name="be.webserviceRequest">
        <map-to xml="AANLOGGEN" ns-prefix="xxx" ns-uri="urn:uniface:applic:services:FACADES_XXX:SF_ACCOUNT"/>
        <field name="login" direct="false" type="java.lang.String">
            <bind-xml name="login" node="element" type="java.lang.String"/>
        </field>
    </class>

    <class name="be.webserviceResponse">
        <map-to xml="tns:AANLOGGEN"/>
        <field name="returnCode" type="java.lang.String" direct="false">
            <bind-xml name="return" type="java.lang.String"/>
        </field>
        <field name="details" type="be.responseDetails">
            <bind-xml name="Item" type="ns1:CS_xxxACCOUNTType" location="GENERATED_PARAMETER_NAME_2"/>
        </field>
        <field name="errors" type="java.lang.String">
            <bind-xml name="GENERATED_PARAMETER_NAME_3" type="java.lang.String"/>
        </field>
    </class>

    <class name="be.responseDetails">
        <map-to xml="Item"/>
        <field name="code" type="java.lang.String" direct="false">
            <bind-xml name="CD" type="java.lang.String"/>
        </field>
        <field name="name" type="java.lang.String" direct="false">
            <bind-xml name="NM" type="java.lang.String"/>
        </field>
    </class>

</mapping>
Spring - Java code:

Code:
public class UnifaceClientApplication extends WebServiceGatewaySupport
{

    public String getFirstName(String login)
    {
        UnifaceUser user = new UnifaceUser();

        UnifaceRequest request = new UnifaceRequest();

        request.setLogin(login);

        UnifaceResponse response = (UnifaceResponse)getWebServiceTemplate().marshalSendAndReceive(request);

        return null;
    }


    public static void main(String args[])
    {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:unifaceClientApplicationContext.xml");
        UnifaceClientApplication client = (UnifaceClientApplication) appContext.getBean("unifaceClientApplication");

        String name = client.getFirstName("xxxxx");

        System.out.println("done");
    }
}

Castor test code:

Code:
public class client
{
    public static void main(String args[])
    {
        try
        {

            Mapping mapping = new Mapping();
            mapping.loadMapping("mapping.xml");


            FileReader reader = new FileReader("d:\\output.xml");
            Unmarshaller unmarshaller = new Unmarshaller(Person.class);
            unmarshaller.setMapping(mapping);
            Person newPerson = (Person) unmarshaller.unmarshal(reader);

        }

        catch (Exception e)
        {
            e.printStackTrace();
        }


    }
}

When Spring passes the XML to castor to unmarschall, I suppose that all the namespaces defined in the SOAP header tags are no longer available for Castor ?

I already tried a lot of things, but for the moment I'm stuk ...

Any help would be nice !

Let me know if you need more feedback.

Just testing code, but compiled when I did copy & paste ...

Thanks.