丶小财 2017-06-01 07:24 采纳率: 50%
浏览 6374
已结题

CXF报错Does it exist in service WSDL?如何处理

我spring整合cxf(cxf-2.6.16.jar),然后发布了一个测试服务,在浏览器中可访问到发布的服务。
图片说明
然后我写了一个客户端去调用我发布的服务,一直报错

 六月 01, 2017 3:03:10 下午 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [springmvc] in context with path [/FeiBao] threw exception [Request processing failed; nested exception is javax.xml.ws.soap.SOAPFaultException: Message part {message.service.com}testStr was not recognized.  (Does it exist in service WSDL?)] with root cause
org.apache.cxf.binding.soap.SoapFault: Message part {message.service.com}testStr was not recognized.  (Does it exist in service WSDL?)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:845)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1705)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1538)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1445)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:570)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:479)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:137)

我在百度上搜索问题答案,有说调用服务的接口和服务端不在同一命名空间下,于是我加上了在@WebService中加上了targetNamespace="message.service.com"属性,但是,依旧报同样的错误。找了几个小时,依旧未找到解决办法,跪求大神解答。

我服务端的cxf配置:

        <bean id="MyTestServiceBean" class="com.webservice.message.impl.MyTestServiceImpl"/> 
        <jaxws:endpoint id="MyTestService" implementor="#MyTestServiceBean" address="/MyTestService">
        </jaxws:endpoint>

服务端的接口文件:

 package com.webservice.message;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService(targetNamespace="message.service.com")
@SOAPBinding(style = Style.RPC)
public interface MyTestService {

    public String testStr(String str);
}

服务端的接口实现:

 package com.webservice.message.impl;

import javax.jws.WebService;

import com.webservice.message.MyTestService;

@WebService (endpointInterface= "com.webservice.message.MyTestService",targetNamespace="message.service.com") 
public class MyTestServiceImpl implements MyTestService {

    @Override
    public String testStr(String str) {
        return "hello," + str;
    }

}

接下来是客户端的部分

客户端cxf的配置:

        <jaxws:client id="MyTestService" serviceClass="com.buick.activity.webservice.service.MyTestService" 
            address="http://127.0.0.1:8080/MessageService/ws/CheckVerifyCodeService?wsdl">
        </jaxws:client>

客户端的接口文件:

package com.buick.activity.webservice.service;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService(targetNamespace="message.service.com")
@SOAPBinding(style = Style.RPC)
public interface MyTestService {

    public String testStr(String str);
}


如果觉得我表意不清晰,欢迎追问。

  • 写回答

1条回答

  • qq_39525180 2017-07-16 01:52
    关注

    兄弟,这个咋解决的

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?