Spring JAX-WS RPC 异常 - javax.xml.ws.WebServiceException: java.net.SocketException: Unexpected end of file from server

伤神 发布于 2016/07/12 17:05
阅读 4K+
收藏 0

用 Spring 的 SimpleJaxWsServiceExporter 将服务暴露成 web service,而在客户端调用的时候,总是抛出如下的异常。javax.xml.ws.WebServiceException: java.net.SocketException: Unexpected end of file from server

org.springframework.remoting.RemoteAccessException: Could not access remote service at [null]; nested exception is javax.xml.ws.WebServiceException: java.net.SocketException: Unexpected end of file from server
	at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.doInvoke(JaxWsPortClientInterceptor.java:565)
	at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.invoke(JaxWsPortClientInterceptor.java:541)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
	at com.sun.proxy.$Proxy25.saveSpitter(Unknown Source)
	at com.habuma.spitter.SpringRPCTest.testJaxws(SpringRPCTest.java:172)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: javax.xml.ws.WebServiceException: java.net.SocketException: Unexpected end of file from server
服务器端的配置
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter" p:baseAddress="http://localhost:8888/webservices/"/>
服务器端所暴露的服务类
@Component
@WebService(serviceName="SpitterWebService")
public class SpitterWebServiceEndpoint{

	@Autowired
	ISpitterRemoteService spitterWebService;
	
	@WebMethod
	public List<SpittleDTO> getSpittlesForSpitter(SpitterDTO spitterDto) {
		
		return spitterWebService.getSpittlesForSpitter(spitterDto);
	}

	@WebMethod
	public List<SpittleDTO> getSpittlesForSpitter(String username) {

		return spitterWebService.getSpittlesForSpitter(username);
	}

	@WebMethod
	public SpitterDTO getSpitter(String username) {

		return spitterWebService.getSpitter(username);
	}

	@WebMethod
	public void saveSpitter(SpitterDTO spitterDto) {
		
		spitterWebService.saveSpitter(spitterDto);
		
	}

	@WebMethod
	public void saveSpittle(SpittleDTO spittleDto) {
		
		spitterWebService.saveSpittle(spittleDto);
		
	}

	@WebMethod
	public void clear() {
		
		spitterWebService.clear();
		
	}	
	
}

Web Service 的相关信息

客户端的 Spring 配置
<bean id="spitterJaxwsRemoteService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"
		  p:wsdlDocumentUrl="http://localhost:8888/webservices/SpitterWebService?wsdl"
		  p:serviceName="SpitterWebService"
		  p:portName="SpitterWebServiceEndpointPort"
		  p:serviceInterface="com.habuma.spitter.remote.service.ISpitterRemoteService"
		  p:namespaceUri="http://service.remote.spitter.habuma.com/"
		  />


客户端的测试代码

@Autowired
	@Qualifier("spitterJaxwsRemoteService")
	ISpitterRemoteService jaxwsRemoteService; 		
	@Test
	public void testJaxws(){
		
		SpitterDTO sr = new SpitterDTO("sh", "ss", "ss@163.com");
		
		SpittleDTO st1 = new SpittleDTO(sr, "how are you?", new Date() );
		
		SpittleDTO st2 = new SpittleDTO(sr, "I'm fine?", new Date() );
		
		SpittleDTO st3 = new SpittleDTO(sr, "and you?", new Date() );
		
		jaxwsRemoteService.saveSpitter( sr );
		
		jaxwsRemoteService.saveSpittle( st1 );
		
		jaxwsRemoteService.saveSpittle( st2 );
		
		jaxwsRemoteService.saveSpittle( st3 );
		
		assertEquals( 3, jaxwsRemoteService.getSpittlesForSpitter( sr ).size() );		
					
		
	}
有人以前遇到过类似的错误吗?怎么解决的呢?


加载中
0
Mr_K
Mr_K

加一个 

@Service

@Component
@WebService(serviceName="SpitterWebService")
@Service
public class SpitterWebServiceEndpoint{}



试下

伤神
伤神
试了,还是报同样的错误
0
Mr_K
伤神
伤神
@Service 加了,endpointInterface 也加上了,可是还是同样的错误,担心是不是 Spring 4.3.0 RPC 的 bug?
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部