|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2008-03-27
引用 Java代码 信息: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: class com.color.webterminal.ws.dto.UserDTO nor any of its super class is known to this context. at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:207) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:63) 信息: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: class com.color.webterminal.ws.dto.UserDTO nor any of its super class is known to this context. at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:207) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:63) 报上面错误啊,按照楼主的做的代码,Help me 有没有用annotation标注JAVA-XML映射呀?
/**
* Web Service传输User信息的DTO.
*
* 分离entity类与web service接口间的耦合,隔绝entity类的修改对接口的影响.
* 使用JAXB 2.0的annotation标注JAVA-XML映射,尽量使用默认约定.
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "User")
public class UserDTO {
protected Integer id;
protected String name;
public Integer getId() {
return id;
}
public void setId(Integer value) {
id = value;
}
public String getName() {
return name;
}
public void setName(String value) {
name = value;
}
}
|
|
| 返回顶楼 | |
|
时间:2008-04-17
我也遇到了同样的问题。
p.s.我用的是 spring 2.5.2 + cxf 2.0.5 bundle |
|
| 返回顶楼 | |
|
时间:2008-04-17
如果只是要开发web serivices的话用xfire就够了吧?cxf 50M的运行库吓死人。
|
|
| 返回顶楼 | |
|
时间:2008-04-18
我也考虑换 xfire 了,不知道 xfire 对 jax-ws 的系列标准支持的怎么样。
|
|
| 返回顶楼 | |
|
时间:2008-04-21
我用的就是 cxf2.0.5 + spring2.5.2 ,还是有NPE
|
|
| 返回顶楼 | |
|
时间:2008-04-21
我想问下,这个要在http里怎么请求,在网上找了个HELLOWORLD的例子,但是只能在java运行,没有http请求路径(http://localhost:8080/cxf/ws/helloWorld?wsdl后面如何把参数传进去)
|
|
| 返回顶楼 | |
|
时间:2008-04-22
NPE 的错误似乎是由于 bus 没有被注入。但是按照楼主的帖子,并不需要注入这个才对。另外,我把 war 部署到 Jboss 4.2,启动服务器的时候,有这样的错误:
09:36:08,607 ERROR [STDERR] 2008-4-22 9:36:08 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass 。。。。 09:36:09,588 ERROR [STDERR] 2008-4-22 9:36:09 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass 。。。。 09:36:10,079 ERROR [STDERR] 2008-4-22 9:36:10 org.apache.cxf.endpoint.ServerImpl initDestination 信息: Setting the server's publish address to be /MoscoService |
|
| 返回顶楼 | |
|
时间:2008-04-22
gigi_ly180 写道 我想问下,这个要在http里怎么请求,在网上找了个HELLOWORLD的例子,但是只能在java运行,没有http请求路径(http://localhost:8080/cxf/ws/helloWorld?wsdl后面如何把参数传进去)
不明白你的问题是什么,你是问在调用的client的时候如何将wsdl 的url 传给client吗? |
|
| 返回顶楼 | |
|
时间:2008-04-22
alexma 写道 NPE 的错误似乎是由于 bus 没有被注入。但是按照楼主的帖子,并不需要注入这个才对。另外,我把 war 部署到 Jboss 4.2,启动服务器的时候,有这样的错误:
09:36:08,607 ERROR [STDERR] 2008-4-22 9:36:08 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass 。。。。 09:36:09,588 ERROR [STDERR] 2008-4-22 9:36:09 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass 。。。。 09:36:10,079 ERROR [STDERR] 2008-4-22 9:36:10 org.apache.cxf.endpoint.ServerImpl initDestination 信息: Setting the server's publish address to be /MoscoService 这些信息不是错误信息,这是因为CXF使用的是j.u.l 而不是Jboss使用的log4j。这样CXF的日志输出就被定向到了错误输出流里面了。 你看到这些日志应该是 INFO level的。 对于NPE,的确是楼主在配置client factory的过程中没有制定bus 而造成的。 如果不想指定bus你可以使用 来定义客户端。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="wsdlLocation"
serviceClass="org.apache.hello_world_soap_http.Greeter"
serviceName="s:SOAPService"
endpointName="s:SoapPort"
xmlns:s="http://apache.org/hello_world_soap_http"
address="http://localhost:8080/simpleWithAddress"
wsdlLocation="wsdl/hello_world.wsdl"/>
或者是将bus配置到JaxWsClientFactory中去
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byName" default-lazy-init="true">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>
<!-- ws client -->
<bean id="identityValidateServiceClient" class="cn.org.coral.admin.service.IdentityValidateService"
factory-bean="identityValidateServiceClientFactory" factory-method="create">
<property name="bus" ref="cxf" />
</bean>
<bean id="identityValidateServiceClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass"
value="cn.org.coral.admin.service.IdentityValidateService" />
<property name="address"
value="http://88.148.29.54:8080/coral/services/IdentityValidateService"/>
</bean>
</beans>
|
|
| 返回顶楼 | |
|
时间:2008-04-22
引用 或者是将bus配置到JaxWsClientFactory中去
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byName" default-lazy-init="true">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>
<!-- ws client -->
<bean id="identityValidateServiceClient" class="cn.org.coral.admin.service.IdentityValidateService"
factory-bean="identityValidateServiceClientFactory" factory-method="create">
<property name="bus" value="#cxf" />
</bean>
<bean id="identityValidateServiceClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass"
value="cn.org.coral.admin.service.IdentityValidateService" />
<property name="address"
value="http://88.148.29.54:8080/coral/services/IdentityValidateService"/>
</bean>
</beans>
多谢楼上回复,按照你的配置,问题已经解决。但是你这段配置有一个错误 <property name="bus" value="#cxf" /> 这一行应该配置在 identityValidateServiceClientFactory 这个 bean 中,如果配置在 identityValidateServiceClient 这个 bean ,会报找不到 property 的错误。 另外,应该写成 <property name="bus" ref="cxf"> 按照你的写法会出现 classcast 错误:不能把 String 转成 Bus 对象。 我修改了你的配置,如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byName" default-lazy-init="true">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>
<!-- ws client -->
<bean id="identityValidateServiceClient" class="cn.org.coral.admin.service.IdentityValidateService"
factory-bean="identityValidateServiceClientFactory" factory-method="create">
</bean>
<bean id="identityValidateServiceClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass"
value="cn.org.coral.admin.service.IdentityValidateService" />
<property name="address"
value="http://88.148.29.54:8080/coral/services/IdentityValidateService"/>
<property name="bus" ref="cxf" />
</bean>
</beans>
|
|
| 返回顶楼 | |





