Java 在CXF+;简单前端&x2B;宙斯盾数据绑定

Java 在CXF+;简单前端&x2B;宙斯盾数据绑定,java,soap,cxf,aegis,Java,Soap,Cxf,Aegis,我正在为SOAP Web服务编写客户端。 我正在使用库CXF。 使用简单的前端。 和宙斯盾数据绑定。 服务器为web方法提供了一个Java接口(名为MediaService),我将该接口导入到客户机项目中。 然后,我使用MediaService.aegis.xml文件为方法参数提供名称(在序列化请求时不命名它们) 以下是我在客户端上使用的代码: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setDa

我正在为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);
我启用了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>
我得到这个错误:

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)
    ...
INFO:创建服务{http://service.soclemedia.mycompany.com/}来自com.mycompany.soclemedia.service.MediaService类的MediaService
2011年11月24日15:18:37 org.apache.cxf.aegis.type.XMLTypeCreator
信息:无法设置aegis架构。没有验证。
java.lang.UnsupportedOperationException:此解析器不支持规范“null”版本“null”
位于javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:489)
位于org.apache.cxf.aegis.type.XMLTypeCreator.(XMLTypeCreator.java:125)
位于org.apache.cxf.aegis.AegisContext.createRootTypeCreator(AegisContext.java:122)
位于org.apache.cxf.aegis.AegisContext.createTypeCreator(AegisContext.java:111)
位于org.apache.cxf.aegis.AegisContext.initialize(AegisContext.java:153)
位于org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:229)
位于org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
位于org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438)
位于org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
位于org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
位于org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
位于org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
位于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>

只是一个想法:

在我最近经历的一个项目中,CXF webservice在Jetty中本地运行时运行良好,而在Weblogic容器中运行时,所有顶级集合都反序列化为null

显然,这是由JAXB中的一个已知错误引起的(对不起,手头没有参考),解决方法是以以下方式包装集合:

public class Wrapper 
{ 
    private List<Reference> references; 
    ... 
}
公共类包装器
{ 
私人名单参考;
... 
}
并让webservice在连线上处理此对象

我希望这也适用于你的问题,如果运气不好的话:-)


/Anders/

列表
和非
列表
?嗯…(如果您添加了服务WSDL的相关部分,这将非常有帮助。)嗯,没有WSDL。制作服务器部件的团队给了我们一个Java接口,该接口有一个返回简单列表的方法。服务器正在使用XFire 1.2.6公开该方法。您是否尝试过任何soap客户端,如soapui
<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>
<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>
public class Wrapper 
{ 
    private List<Reference> references; 
    ... 
}