我从JBoss的4迁移一个古老的JAX-WS 2.1 Web服务到WebSphere 7来源返回类型JAX-WS Web服务大多数@WebMethod
部件全部是这样的:与在WebSphere
@WebMethod
public Source someMethod(){
Source source = null;
try{
source = ServiceActions.someMethodWorker();
}
catch(Throwable throwable){
source = ServiceActions.handleThrowable("Error occured in method someMethod", throwable);
}
return source;
}
ServiceActions.someMethodWorker()
通常熄灭并取入该数据填充一个JAXB结构,执法官成XML并返回XML这样的StreamSource
:
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
JAXBContext jc = JAXBContext.newInstance();
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(someJaxBObjectHierarchy, byteArrayOutputStream);
return new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
此Web服务运行在JBoss 4(与JAX-WS和JAXB库就好了)和GlassFish 3.1,但网络phere 7一直给我下面的错误我使用客户端对Web服务的任何时间:
javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class javax.xml.transform.stream.StreamSource nor any of its super class is known to this context.]
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
起初看起来这似乎是JAXB类型绑定问题;不过,我在任何地方都添加了@XmlSeeAlso(StreamSource.class)
,但我仍然收到错误消息。
有人会知道为什么这在WebSphere 7上失败了吗?
谢谢!
编辑/解决方案:的解决方案是使用byte[]
返回类型,而不是Source
GlassFish和JBoss的做着相比JAX-WS规范这使我相信,Source
返回类型是确定的额外的东西。
,而不是我的方法返回new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))
他们现在只返回byteArrayOutputStream.toByteArray()
我不确定解决方案是什么,但它听起来像是WebSphere 7中的一个错误。对于此用例,因为您正在返回一个'Source',JAX-WS实现不需要利用JAXB impl来执行捆绑。添加'@XmlSeeAlso(StreamSource.class)'与你想做的事情相反,因为它会强制引入JAXB,并且会抱怨'Source'类。 – 2011-12-19 20:15:49
如果是这种情况,是否有办法关闭端点的JAXB? – faffy 2011-12-19 21:20:10