Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP response wrongly deserializing as null in CXF + Simple frontend + Aegis databinding
    text
    copied!<p>I'm writting a client for a SOAP Web Service. I'm using the library CXF. With the Simple frontend. And the Aegis databinding. The server is providing a Java interface (named MediaService) for the web methods, and I import that interface in the client project. I then use a MediaService.aegis.xml file to provide names for the method parameters (for them not to be named and when serializing the request).</p> <p>Here is the code I use on the client:</p> <pre><code>ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setDataBinding(new AegisDatabinding()); factory.setServiceClass(MediaService.class); factory.setAddress(urlMediaServer); MediaService service = (MediaService) factory.create(); final List&lt;Reference&gt; listeReferences = service.sendMedia(bu, media); </code></pre> <p>The service interface is like this:</p> <pre><code>public interface MediaService { public List sendMedia(String bu, Media media) throws Exception; } </code></pre> <p>I have enabled XML stream logging so that I see the XML stream that is sent to the server, and the stream it returns.</p> <p>Here are the streams:</p> <p>Request:</p> <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Body&gt; &lt;ns1:sendMedia xmlns:ns1="http://service.soclemedia.mycompany.com/"&gt; &lt;ns1:bu&gt;sc_phx&lt;/ns1:bu&gt; &lt;ns1:media&gt; &lt;ns2:productId xmlns:ns2="http://bo.soclemedia.mycompany.com"&gt;TEST_CODE&lt;/ns2:productId&gt; &lt;ns2:mediaName xmlns:ns2="http://bo.soclemedia.mycompany.com"&gt;test.png&lt;/ns2:mediaName&gt; &lt;/ns1:media&gt; &lt;/ns1:sendMedia&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>Response:</p> <pre><code>&lt;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"&gt; &lt;soap:Body&gt; &lt;sendMediaResponse xmlns="http://service.soclemedia.mycompany.com"&gt; &lt;out xmlns="http://service.soclemedia.mycompany.com"&gt; &lt;ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com"&gt; &lt;subType xmlns="http://bo.soclemedia.mycompany.com"&gt;standard&lt;/subType&gt; &lt;typeMedia xmlns="http://bo.soclemedia.mycompany.com"&gt;photo&lt;/typeMedia&gt; &lt;/ns1:Reference&gt; &lt;ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com"&gt; &lt;subType xmlns="http://bo.soclemedia.mycompany.com"&gt;standard&lt;/subType&gt; &lt;typeMedia xmlns="http://bo.soclemedia.mycompany.com"&gt;photo&lt;/typeMedia&gt; &lt;/ns1:Reference&gt; &lt;/out&gt; &lt;/sendMediaResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>The service is called, it replies and the client receive the correct reply. But in the client, the line service.sendMedia(bu, media) making the Web Service call returns null. There is something wrong with deserializing the reply. Do you have any idea of what went wrong and how to fix it?</p> <p>Best regards.</p> <h2>UPDATE:</h2> <p>I forgot to mention that when I call this method:</p> <pre><code>MediaService service = (MediaService) factory.create(); </code></pre> <p>I get this error:</p> <pre><code>INFO: Creating Service {http://service.soclemedia.mycompany.com/}MediaService from class com.mycompany.soclemedia.service.MediaService 24 nov. 2011 15:18:37 org.apache.cxf.aegis.type.XMLTypeCreator &lt;clinit&gt; INFO: Could not set aegis schema. Not validating. java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null" at javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:489) at org.apache.cxf.aegis.type.XMLTypeCreator.&lt;clinit&gt;(XMLTypeCreator.java:125) at org.apache.cxf.aegis.AegisContext.createRootTypeCreator(AegisContext.java:122) at org.apache.cxf.aegis.AegisContext.createTypeCreator(AegisContext.java:111) at org.apache.cxf.aegis.AegisContext.initialize(AegisContext.java:153) at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:229) at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:153) ... </code></pre> <p>Here is my cxf.xml:</p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"&gt; &lt;cxf:bus&gt; &lt;cxf:features&gt; &lt;cxf:logging/&gt; &lt;/cxf:features&gt; &lt;/cxf:bus&gt; &lt;/beans&gt; </code></pre> <h2>UPDATE 2:</h2> <p>And here is my MediaService.aegis.xml:</p> <pre><code>&lt;mappings&gt; &lt;mapping&gt; &lt;method name="sendMedia"&gt; &lt;parameter index="0" mappedName="bu"/&gt; &lt;parameter index="1" mappedName="media"/&gt; &lt;return-type componentType="com.mycompany.soclemedia.bo.Reference" /&gt; &lt;/method&gt; &lt;/mapping&gt; &lt;/mappings&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload