尝试调用Web服务时发生异常 [英] exception when trying to call webservice

查看:174
本文介绍了尝试调用Web服务时发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从 SOAPUI 调用服务时,出现以下异常。当我在浏览器中打开端点时,它会显示wsdl值。

I am getting the below exception when trying to call service from SOAPUI. When I open the endpoint in browser, it displays the wsdl fine.

WARN  org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://contract.premsisc.usst.com/}PaidClaimFacadeService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part {http://contract.premsisc.uss`enter code here`t.com/}findPaidClaims was not recognized.  (Does it exist in service WSDL?)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:194)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113)
    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:461)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:188)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:932)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)

我的wsdl与WAS 7服务器一样

My wsdl as in WAS 7 server

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://contract.premsisc.usst.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PaidClaimFacadeService" targetNamespace="http://contract.premsisc.usst.com/">
<wsdl:types>
<xs:schema xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://contract.premsisc.usst.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://contract.premsisc.usst.com/">
<xs:element name="findPaidClaims" type="tns:findPaidClaims"/>
<xs:element name="findPaidClaimsResponse" type="tns:findPaidClaimsResponse"/>
<xs:complexType name="findPaidClaims">
<xs:sequence>
<xs:element minOccurs="0" name="Product" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="findPaidClaimsResponse">
<xs:sequence>
<xs:element name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:element name="PremDiscountService" type="tns:PremDiscountService"/>
<xs:complexType name="PremDiscountService">
<xs:sequence/>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="findPaidClaims">
<wsdl:part element="tns:findPaidClaims" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="PremDiscountServiceException">
<wsdl:part element="tns:PremDiscountService" name="PremDiscountServiceException"></wsdl:part>
</wsdl:message>
<wsdl:message name="findPaidClaimsResponse">
<wsdl:part element="tns:findPaidClaimsResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="PaidClaimFacade">
<wsdl:operation name="findPaidClaims">
<wsdl:input message="tns:findPaidClaims" name="findPaidClaims"></wsdl:input>
<wsdl:output message="tns:findPaidClaimsResponse" name="findPaidClaimsResponse"></wsdl:output>
<wsdl:fault message="tns:PremDiscountServiceException" name="PremDiscountServiceException"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PaidClaimFacadeServiceSoapBinding" type="tns:PaidClaimFacade">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="findPaidClaims">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="findPaidClaims">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="findPaidClaimsResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="PremDiscountServiceException">
<soap:fault name="PremDiscountServiceException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PaidClaimFacadeService">
<wsdl:port binding="tns:PaidClaimFacadeServiceSoapBinding" name="PaidClaimFacadePort">
<soap:address location="http://localhost:9084/premdisc/services/PaidClaimFacadeService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

我在 SOAPUI 中的肥皂请求:

My Soap Request in SOAPUI :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:con="http://contract.premsisc.usst.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <con:findPaidClaims>
         <!--Optional:-->
         <Product>abc</Product>
      </con:findPaidClaims>
   </soapenv:Body>
</soapenv:Envelope>

Soap UI中的肥皂响应:

Soap Response in Soap UI:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Message part {http://contract.premsisc.usst.com/}findPaidClaims was not recognized.  (Does it exist in service WSDL?)</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

这就是我配置jaxws:endpoint

and this is how I configured the jaxws:endpoint

<jaxws:endpoint id="paidClaimWs" implementor="#paidClaimFacadeImpl"
        address="/PaidClaimFacadeService" wsdlLocation="/wsdl/PaidClaimFacade.wsdl"
        serviceName="msg:PaidClaimFacadeService" endpointName="msg:PaidClaimFacadePort"
        xmlns:msg="http://contract.premsisc.usst.com/">
    </jaxws:endpoint>


推荐答案

这意味着您正在调用的操作不会在您的 WSDL 文件中退出。

This means that you are calling an operation which does not exits in your WSDL file.

{http://contract.premsisc.usst.com/}findPaidClaims was not recognized

这是您的目标名称空间: http://contract.premsisc.usst.com/
这是您的操作: findPaidClaims

This is your target name space: http://contract.premsisc.usst.com/ And this is your operation: findPaidClaims

如果您检查 WSDL ,您会发现没有这样的操作: findPaidClaims

If you'll check your WSDL you will see that there is no such operation like: findPaidClaims.

编辑

现在问题很明显。 WSDL文件中的名称空间错误。
这是固定的WSDL,它将起作用。我不知道您是否对WSDL文件进行了一些验证,但是我的IntelliJ会显示错误。所以我修复了它们:

Now the problem is clear. Your namespaces in WSDL file are wrong. This is fixed WSDL and it will work. I don't know if you run some validation of your WSDL file, but my IntelliJ show the errors. So I fixed them:

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:tns="http://contract.premdisc.hcsc.com/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  name="PaidClaimFacadeService"
                  targetNamespace="http://contract.premdisc.hcsc.com/">
    <wsdl:types>
        <xs:schema xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                   xmlns:tns="http://contract.premsisc.usst.com/types"
                   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                   xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   attributeFormDefault="unqualified"
                   elementFormDefault="unqualified"
                   targetNamespace="http://contract.premsisc.usst.com/types">
            <xs:element name="findPaidClaims" type="tns:findPaidClaims"/>
            <xs:element name="findPaidClaimsResponse" type="tns:findPaidClaimsResponse"/>
            <xs:complexType name="findPaidClaims">
                <xs:sequence>
                    <xs:element minOccurs="0" name="Product" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="findPaidClaimsResponse">
                <xs:sequence>
                    <xs:element name="return" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="PremDiscountService" type="tns:PremDiscountService"/>
            <xs:complexType name="PremDiscountService">
                <xs:sequence/>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="findPaidClaims">
        <wsdl:part element="tns:findPaidClaims" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="PremDiscountServiceException">
        <wsdl:part element="tns:PremDiscountService" name="PremDiscountServiceException"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="findPaidClaimsResponse">
        <wsdl:part element="tns:findPaidClaimsResponse" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:portType name="PaidClaimFacade">
        <wsdl:operation name="findPaidClaims">
            <wsdl:input message="tns:findPaidClaims" name="findPaidClaims"></wsdl:input>
            <wsdl:output message="tns:findPaidClaimsResponse" name="findPaidClaimsResponse"></wsdl:output>
            <wsdl:fault message="tns:PremDiscountServiceException" name="PremDiscountServiceException"></wsdl:fault>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="PaidClaimFacadeServiceSoapBinding" type="tns:PaidClaimFacade">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="findPaidClaims">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="findPaidClaims">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="findPaidClaimsResponse">
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="PremDiscountServiceException">
                <soap:fault name="PremDiscountServiceException" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="PaidClaimFacadeService">
        <wsdl:port binding="tns:PaidClaimFacadeServiceSoapBinding" name="PaidClaimFacadePort">
            <soap:address location="http://localhost:9084/premdisc/services/PaidClaimFacadeService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

问题是您的 xmlns:tns具有不同的命名空间 targetNamespace 。仔细查看您的WSDL。

The problem was that you had different namespace as your xmlns:tns and targetNamespace. Look closely at your WSDL.

xmlns:tns="http://contract.premdisc.hcsc.com/"
targetNamespace="http://contract.premsisc.usst.com/"

您在文件中看到它们是不同的,但必须相同。对于XSD,您需要使用其他名称空间。像这样的东西:

You see that in your file they are different, but they must be the same. And for your XSD you need to use different namespace. Something like:

xmlns:tns="http://contract.premsisc.usst.com/types"

就像在您的文件中一样:

As it was in your file:

xmlns:tns="http://contract.premsisc.usst.com/"
targetNamespace="http://contract.premdisc.hcsc.com/"

屁股你可以看到它们也不同。将我修复的文件与您的文件进行比较,就会发现区别。尝试使用固定文件,它将起作用。

Ass you can see they are also different. Compare the file I fixed and your file and will see the difference. Try it with fixed file and it will work.

这篇关于尝试调用Web服务时发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆