webservice接口调用异常两种(Unexpected wrapper element,Unmarshalling Error: 意外的元素)

webservice接口调用异常两种

(1)Unexpected wrapper element {xxx}xx found. Expected {xxx}xx.

后台错误:

20:47:45.824 [http-nio-8080-exec-8] WARN  o.a.c.p.PhaseInterceptorChain - [doLog,475] - Interceptor for {http://impl.service.webservice.web.ruoyi.com/}TestOneServiceImplService#{http://service.webservice.web.ruoyi.com/}apiOne has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element {http://impl.service.webservice.web.ruoyi.com}apiOne found.   Expected {http://service.webservice.web.ruoyi.com/}apiOne.
	at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:107)

后台错误

前台错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Client</faultcode>
            <faultstring>Unexpected wrapper element {http://impl.service.webservice.web.ruoyi.com}apiOne found.   Expected {http://service.webservice.web.ruoyi.com/}apiOne.</faultstring>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

前台错误
错误原因:
webservice接口上的@Webservice注解缺失 targetNamespace 属性(一般为接口实现类包路径倒序),增加该属性后解决。如图:
解决方式

(2)Unmarshalling Error: 意外的元素 所需元素为<{}

后台错误:

Caused by: com.sun.istack.internal.SAXParseException2: 意外的元素 (uri:"http://impl.service.webservice.web.ruoyi.com", local:"data")。所需元素为<{}arg0>
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726)

后台错误
前台错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Client</faultcode>
            <faultstring>Unmarshalling Error: 意外的元素 (uri:"http://impl.service.webservice.web.ruoyi.com", local:"data")。所需元素为&lt;{}arg0> </faultstring>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

前台错误
错误原因:
功能方法的注解@WebParam 缺失属性,必须包含name和targetNamespace属性,增加相关属性后解决。如图:
解决方式
PS:注意点!!! 如果需要显示其参数名和参数类型等信息,还需要添加其他注解及属性,完整版请查看我博文:(springboot 创建webservice服务接口:https://blog.csdn.net/yssa1125001/article/details/115679689)

最终效果如图,可以看到相关参数被成功接收到:
最终效果

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值