Soap服务在本地工作,但在另一台服务器上引发ClassCast异常

Adi*_*tzu 5 java websphere soap web-services

有人可以帮我解决一个奇怪的问题吗?

我有一个服务:

@WebMethod
@WebResult(name = "sendCustomerCommunicationResponse", targetNamespace = "......something/Underwriting/Correspondance/V1", partName = "Body")
public SendCustomerCommunicationResponse sendCustomerCommunication(
    @WebParam(name = "sendCustomerCommunicationRequest", targetNamespace = "........something/Underwriting/Correspondance/V1", partName = "Body")
    SendCustomerCommunicationRequest body)
    throws ServiceException_Exception, SystemException_Exception
;
Run Code Online (Sandbox Code Playgroud)

在本地我称之为:

SendCustomerCommunicationResponse response = correspondanceServicePort.sendCustomerCommunication(sendCustomerCommunicationRequest);
Run Code Online (Sandbox Code Playgroud)

这很好用.但是当我在另一台服务器上部署应用程序时,我收到了:

"java.lang.ClassCastException: 
    it.usi.xframe.ub1.batch.services.esb.SendCustomerCommunicationRequest incompatible with 
    it.usi.xframe.ub1.batch.services.esb.SendCustomerCommunicationResponse"
Run Code Online (Sandbox Code Playgroud)

PS应用程序在WebSphere服务器上运行

请求是:

<soapenv:Envelope ...someSchema...>
   <soapenv:Header>
      <v1:TechnicalHeader>
         <v1:correlationId>12742</v1:correlationId>
         <v1:sender>userName</v1:sender>
         <v1:countryCode/>
         <v1:channelId/>
         <v1:userID>userName</v1:userID>
         <v1:operationId>CHANGE_STATUS</v1:operationId>
      </v1:TechnicalHeader>
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                                    <wsse:UsernameToken>
                                                <wsse:Username>someUser</wsse:Username>
                                                <wsse:Password>somePassoword</wsse:Password>
                                    </wsse:UsernameToken>
                        </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <v11:sendCustomerCommunicationRequest>
         <v11:eventCode>{"header":{"publishingDate":1474016634749,"eventId":"DEL-NEG","applicationCode":"UB3","correlationId":"9999","language":"IT","channelId":"MOB"},"body":{"ndg":"5106215","additionalInfo":{}}}</v11:eventCode>
      </v11:sendCustomerCommunicationRequest>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

bos*_*sco 1

也许这可能是 WebSphere JAXB 问题,与您正在使用的版本相关,或者您的服务器可能会错过一些修复。看看文档怎么说

JAXB Unmarshaller 在运行时生成存根类以帮助解组文档。这些生成的类会被缓存,并且可以由应用程序中的其他 JAXBContext 重用。

当 aJAXBContext包含具有元素通配符(即 )的类时@XmlAnyElement,Unmarshaller 可能会使用来自另一个的不兼容的生成存根类JAXBContext,这可能会导致ClassCastException在解组期间抛出异常。通过改进对先前生成的存根类进行的冲突检查来解决该问题,以便JAXBContext如果在缓存中找到的先前生成的存根类不兼容,则从当前存根类生成新的存根类。

由于 IBM 的性质,无论您使用什么版本,这都很难猜测。另外,请参考其他一些修复: