SOAP 响应在 CXF + 简单前端 + Aegis 数据绑定中错误地反序列化为 null
我正在为 SOAP Web 服务编写客户端。我正在使用库 CXF。使用简单前端。和宙斯盾数据绑定。服务器为 Web 方法提供了一个 Java 接口(名为 MediaService),我将该接口导入到客户端项目中。然后,我使用 MediaService.aegis.xml 文件来提供方法参数的名称(以便不命名它们以及在序列化请求时)。
以下是我在客户端上使用的代码:
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setDataBinding(new AegisDatabinding());
factory.setServiceClass(MediaService.class);
factory.setAddress(urlMediaServer);
MediaService service = (MediaService) factory.create();
final List<Reference> listeReferences = service.sendMedia(bu, media);
服务接口如下所示:
public interface MediaService
{
public List sendMedia(String bu, Media media) throws Exception;
}
我已启用 XML 流日志记录,以便看到发送到服务器的 XML 流及其返回的流。
以下是流:
请求:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:sendMedia xmlns:ns1="http://service.soclemedia.mycompany.com/">
<ns1:bu>sc_phx</ns1:bu>
<ns1:media>
<ns2:productId xmlns:ns2="http://bo.soclemedia.mycompany.com">TEST_CODE</ns2:productId>
<ns2:mediaName xmlns:ns2="http://bo.soclemedia.mycompany.com">test.png</ns2:mediaName>
</ns1:media>
</ns1:sendMedia>
</soap:Body>
</soap:Envelope>
响应:
<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>
<sendMediaResponse xmlns="http://service.soclemedia.mycompany.com">
<out xmlns="http://service.soclemedia.mycompany.com">
<ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com">
<subType xmlns="http://bo.soclemedia.mycompany.com">standard</subType>
<typeMedia xmlns="http://bo.soclemedia.mycompany.com">photo</typeMedia>
</ns1:Reference>
<ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com">
<subType xmlns="http://bo.soclemedia.mycompany.com">standard</subType>
<typeMedia xmlns="http://bo.soclemedia.mycompany.com">photo</typeMedia>
</ns1:Reference>
</out>
</sendMediaResponse>
</soap:Body>
</soap:Envelope>
服务被调用,它回复,客户端收到正确的回复。但在客户端中,使 Web 服务调用的行 service.sendMedia(bu, media) 返回 null。反序列化回复有问题。您知道哪里出了问题以及如何解决它吗?
此致敬意。
更新:
当我调用此方法时,我忘了提到:
MediaService service = (MediaService) factory.create();
我收到此错误:
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 <clinit>
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.<clinit>(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)
...
这是我的cxf.xml:
<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">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
</beans>
更新 2:
这是我的MediaService.aegis.xml:
<mappings>
<mapping>
<method name="sendMedia">
<parameter index="0" mappedName="bu"/>
<parameter index="1" mappedName="media"/>
<return-type componentType="com.mycompany.soclemedia.bo.Reference" />
</method>
</mapping>
</mappings>