我正在尝试将JAX-WS服务客户端部署到WebSphere v8.5.5应用服务器上,并使用它来调用部署在不同服务器中的SOAP服务。我终于解决了所有的安全问题并且它正在成功地发出请求,但是当它将响应转换回JAXB对象时,它会抛出上下文问题而无法找到合适的类。
[1/20/17 16:21:56:131 EST] 000001aa JAXBUtils 3 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext new JAXBContext constructed, elapsed time msec: 1934
[1/20/17 16:21:56:131 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext [created or retrieved from hard map] for [@preference.v1, @preference.v1_0.commonheadertypes, @preference.v1_0.filterheader, @preference.v1_0.filterheaderresponse, @preference.v1_0.getfilterheaderrequest, @preference.v1_0.getpreferencesrequest, @preference.v1_0.getpreferencesresponse, @preference.v1_0.isaliveresponse, @preference.v1_0.preference, @preference.v1_0.setpreferencesrequest, @preference.v1_0.setpreferencesresponse, [preference.v1.ObjectFactory], [preference.v1_0.commonheadertypes.ObjectFactory], [preference.v1_0.commonheadertypes.RequestHeader], [preference.v1_0.filterheader.ObjectFactory], [preference.v1_0.filterheaderresponse.FilterHeaderResponse], [preference.v1_0.filterheaderresponse.ObjectFactory], [preference.v1_0.getfilterheaderrequest.GetFilterHeaderRequest], [preference.v1_0.getfilterheaderrequest.ObjectFactory], [preference.v1_0.getpreferencesrequest.GetPreferencesRequest], [preference.v1_0.getpreferencesrequest.ObjectFactory], [preference.v1_0.getpreferencesresponse.GetPreferencesResponse], [preference.v1_0.getpreferencesresponse.ObjectFactory], [preference.v1_0.isaliveresponse.ObjectFactory], [preference.v1_0.isaliveresponse.Response], [preference.v1_0.preference.ObjectFactory], [preference.v1_0.setpreferencesrequest.ObjectFactory], [preference.v1_0.setpreferencesrequest.SetPreferencesRequest], [preference.v1_0.setpreferencesresponse.ObjectFactory], [preference.v1_0.setpreferencesresponse.SetPreferencesResponse], preference.v1, preference.v1.0.commonheadertypes, preference.v1.0.filterheader, preference.v1.0.filterheaderresponse, preference.v1.0.getfilterheaderrequest, preference.v1.0.getpreferencesrequest, preference.v1.0.getpreferencesresponse, preference.v1.0.isaliverequest, preference.v1.0.isaliveresponse, preference.v1.0.preference, preference.v1.0.setpreferencesrequest, preference.v1.0.setpreferencesresponse, preference.v1_0.commonheadertypes, preference.v1_0.commonheadertypes > preference.v1.0.commonheadertypes, preference.v1_0.filterheader, preference.v1_0.filterheaderresponse, preference.v1_0.getfilterheaderrequest, preference.v1_0.getfilterheaderrequest > preference.v1.0.getfilterheaderrequest, preference.v1_0.getpreferencesrequest, preference.v1_0.getpreferencesrequest > preference.v1.0.getpreferencesrequest, preference.v1_0.getpreferencesresponse, preference.v1_0.isaliveresponse, preference.v1_0.preference, preference.v1_0.setpreferencesrequest, preference.v1_0.setpreferencesrequest > preference.v1.0.setpreferencesrequest, preference.v1_0.setpreferencesresponse, preferences.v1]
[1/20/17 16:21:56:132 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext also stored by the list of valid packages:[]
[1/20/17 16:21:56:132 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext constructionType= BY_CLASS_ARRAY_PLUS_ARRAYS
[1/20/17 16:21:56:133 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContextValue = org.apache.axis2.jaxws.message.databinding.JAXBUtils$JAXBContextValue@1b35cebd
[1/20/17 16:21:56:133 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext = com.ibm.xml.xlxp2.jaxb.JAXBContextImpl@b2008b5b
[1/20/17 16:21:56:134 EST] 000001aa JAXBUtils 3 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContextCreate: creation completed
[1/20/17 16:21:56:134 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBUnmarshaller Unmarshaller created [not in pool]
[1/20/17 16:21:56:152 EST] 000001aa DocLitWrapped 1 org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMinimalMethodMarshaller demarshalResponse fail demarshalResponse e=org.apache.axiom.om.OMException: javax.xml.bind.JAXBException: preference.v1_0.filterheaderresponse.FilterHeaderResponse is not known to this context
[1/20/17 16:21:56:156 EST] 000001aa ExceptionFact 1 org.apache.axis2.jaxws.ExceptionFactory logRootCause Root Cause:javax.xml.bind.JAXBException: preference.v1_0.filterheaderresponse.FilterHeaderResponse is not known to this context
如果我查看整个堆栈跟踪,我可以看到上下文甚至从硬地图中检索所有对象。此外,它认为它需要创建一个新的JAXBContext,即使已经为那个工作正常的请求创建了一个。下面是构建请求上下文时的跟踪,它确实找到了相应的包。
[1/20/17 16:21:51:959 EST] 000001aa JAXBUtils 3 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext new JAXBContext constructed, elapsed time msec: 1369
[1/20/17 16:21:51:960 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext jaxbMap.put3, validPackagesKey[[preference.v1, preference.v1_0.commonheadertypes, preference.v1_0.filterheader, preference.v1_0.filterheaderresponse, preference.v1_0.getfilterheaderrequest, preference.v1_0.getpreferencesrequest, preference.v1_0.getpreferencesresponse, preference.v1_0.isaliveresponse, preference.v1_0.preference, preference.v1_0.setpreferencesrequest, preference.v1_0.setpreferencesresponse]] softRef2[java.lang.ref.SoftReference@b0f234e3]
[1/20/17 16:21:51:960 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext [created or retrieved from hard map] for [@preference.v1, @preference.v1_0.commonheadertypes, @preference.v1_0.filterheader, @preference.v1_0.filterheaderresponse, @preference.v1_0.getfilterheaderrequest, @preference.v1_0.getpreferencesrequest, @preference.v1_0.getpreferencesresponse, @preference.v1_0.isaliveresponse, @preference.v1_0.preference, @preference.v1_0.setpreferencesrequest, @preference.v1_0.setpreferencesresponse, [preference.v1.ObjectFactory], [preference.v1_0.commonheadertypes.ObjectFactory], [preference.v1_0.commonheadertypes.RequestHeader], [preference.v1_0.filterheader.ObjectFactory], [preference.v1_0.filterheaderresponse.FilterHeaderResponse], [preference.v1_0.filterheaderresponse.ObjectFactory], [preference.v1_0.getfilterheaderrequest.GetFilterHeaderRequest], [preference.v1_0.getfilterheaderrequest.ObjectFactory], [preference.v1_0.getpreferencesrequest.GetPreferencesRequest], [preference.v1_0.getpreferencesrequest.ObjectFactory], [preference.v1_0.getpreferencesresponse.GetPreferencesResponse], [preference.v1_0.getpreferencesresponse.ObjectFactory], [preference.v1_0.isaliveresponse.ObjectFactory], [preference.v1_0.isaliveresponse.Response], [preference.v1_0.preference.ObjectFactory], [preference.v1_0.setpreferencesrequest.ObjectFactory], [preference.v1_0.setpreferencesrequest.SetPreferencesRequest], [preference.v1_0.setpreferencesresponse.ObjectFactory], [preference.v1_0.setpreferencesresponse.SetPreferencesResponse], preference.v1, preference.v1.0.commonheadertypes, preference.v1.0.filterheader, preference.v1.0.filterheaderresponse, preference.v1.0.getfilterheaderrequest, preference.v1.0.getpreferencesrequest, preference.v1.0.getpreferencesresponse, preference.v1.0.isaliverequest, preference.v1.0.isaliveresponse, preference.v1.0.preference, preference.v1.0.setpreferencesrequest, preference.v1.0.setpreferencesresponse, preference.v1_0.commonheadertypes, preference.v1_0.commonheadertypes > preference.v1.0.commonheadertypes, preference.v1_0.filterheader, preference.v1_0.filterheaderresponse, preference.v1_0.getfilterheaderrequest, preference.v1_0.getfilterheaderrequest > preference.v1.0.getfilterheaderrequest, preference.v1_0.getpreferencesrequest, preference.v1_0.getpreferencesrequest > preference.v1.0.getpreferencesrequest, preference.v1_0.getpreferencesresponse, preference.v1_0.isaliveresponse, preference.v1_0.preference, preference.v1_0.setpreferencesrequest, preference.v1_0.setpreferencesrequest > preference.v1.0.setpreferencesrequest, preference.v1_0.setpreferencesresponse, preferences.v1]
[1/20/17 16:21:51:961 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext also stored by the list of valid packages:[preference.v1, preference.v1_0.commonheadertypes, preference.v1_0.filterheader, preference.v1_0.filterheaderresponse, preference.v1_0.getfilterheaderrequest, preference.v1_0.getpreferencesrequest, preference.v1_0.getpreferencesresponse, preference.v1_0.isaliveresponse, preference.v1_0.preference, preference.v1_0.setpreferencesrequest, preference.v1_0.setpreferencesresponse]
[1/20/17 16:21:51:961 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext constructionType= BY_CONTEXT_PATH
[1/20/17 16:21:51:962 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContextValue = org.apache.axis2.jaxws.message.databinding.JAXBUtils$JAXBContextValue@231f9d4e
[1/20/17 16:21:51:962 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContext = com.ibm.xml.xlxp2.jaxb.JAXBContextImpl@6914a4cd
[1/20/17 16:21:51:962 EST] 000001aa JAXBUtils 3 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext JAXBContextCreate: creation completed
[1/20/17 16:21:51:963 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBMarshaller Marshaller created [not in pool]
[1/20/17 16:21:52:037 EST] 000001aa ContextUtils 1 org.apache.axis2.jaxws.context.utils.ContextUtils _isJAXBRemoveIllegalChars isJAXBRemoveIllegalChars returns the default: false
[1/20/17 16:21:52:037 EST] 000001aa ContextUtils 1 org.apache.axis2.jaxws.context.utils.ContextUtils getRelatedMessageContext Enter getRelatedMessageContext for:[MessageContext: logID=74ca574be105a3cab3233c4f8e1638f3fe4fbae7c632556e]
[1/20/17 16:21:52:038 EST] 000001aa ContextUtils 1 org.apache.axis2.jaxws.context.utils.ContextUtils getRelatedMessageContext Exit getRelatedMessageContext related messageContext is[MessageContext: logID=64ca574be105a3cab3233c4f8e1638f3fe4fbae7c632556e]
[1/20/17 16:21:52:038 EST] 000001aa ContextUtils 1 org.apache.axis2.jaxws.context.utils.ContextUtils _isJAXBRemoveIllegalChars isJAXBRemoveIllegalChars returns the default: false
[1/20/17 16:21:52:069 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils releaseJAXBMarshaller Marshaller placed back into pool
[1/20/17 16:21:52:069 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils releaseJAXBMarshaller Marshaller = com.ibm.xml.xlxp2.jaxb.marshal.MarshallerImpl@e4f59217
[1/20/17 16:21:52:070 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils releaseJAXBMarshaller JAXBContext = com.ibm.xml.xlxp2.jaxb.JAXBContextImpl@6914a4cd
[1/20/17 16:21:52:070 EST] 000001aa BlockImpl 1 org.apache.axis2.jaxws.message.impl.BlockImpl outputTo End outputTo
[1/20/17 16:21:52:071 EST] 000001aa BlockImpl 1 org.apache.axis2.jaxws.message.impl.BlockImpl outputTo Start outputTo
[1/20/17 16:21:52:071 EST] 000001aa BlockImpl 1 org.apache.axis2.jaxws.message.impl.BlockImpl outputTo Write business object
[1/20/17 16:21:52:072 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext key[[@preference.v1, @preference.v1_0.commonheadertypes, @preference.v1_0.filterheader, @preference.v1_0.filterheaderresponse, @preference.v1_0.getfilterheaderrequest, @preference.v1_0.getpreferencesrequest, @preference.v1_0.getpreferencesresponse, @preference.v1_0.isaliveresponse, @preference.v1_0.preference, @preference.v1_0.setpreferencesrequest, @preference.v1_0.setpreferencesresponse, [preference.v1.ObjectFactory], [preference.v1_0.commonheadertypes.ObjectFactory], [preference.v1_0.commonheadertypes.RequestHeader], [preference.v1_0.filterheader.ObjectFactory], [preference.v1_0.filterheaderresponse.FilterHeaderResponse], [preference.v1_0.filterheaderresponse.ObjectFactory], [preference.v1_0.getfilterheaderrequest.GetFilterHeaderRequest], [preference.v1_0.getfilterheaderrequest.ObjectFactory], [preference.v1_0.getpreferencesrequest.GetPreferencesRequest], [preference.v1_0.getpreferencesrequest.ObjectFactory], [preference.v1_0.getpreferencesresponse.GetPreferencesResponse], [preference.v1_0.getpreferencesresponse.ObjectFactory], [preference.v1_0.isaliveresponse.ObjectFactory], [preference.v1_0.isaliveresponse.Response], [preference.v1_0.preference.ObjectFactory], [preference.v1_0.setpreferencesrequest.ObjectFactory], [preference.v1_0.setpreferencesrequest.SetPreferencesRequest], [preference.v1_0.setpreferencesresponse.ObjectFactory], [preference.v1_0.setpreferencesresponse.SetPreferencesResponse], preference.v1, preference.v1.0.commonheadertypes, preference.v1.0.filterheader, preference.v1.0.filterheaderresponse, preference.v1.0.getfilterheaderrequest, preference.v1.0.getpreferencesrequest, preference.v1.0.getpreferencesresponse, preference.v1.0.isaliverequest, preference.v1.0.isaliveresponse, preference.v1.0.preference, preference.v1.0.setpreferencesrequest, preference.v1.0.setpreferencesresponse, preference.v1_0.commonheadertypes, preference.v1_0.commonheadertypes > preference.v1.0.commonheadertypes, preference.v1_0.filterheader, preference.v1_0.filterheaderresponse, preference.v1_0.getfilterheaderrequest, preference.v1_0.getfilterheaderrequest > preference.v1.0.getfilterheaderrequest, preference.v1_0.getpreferencesrequest, preference.v1_0.getpreferencesrequest > preference.v1.0.getpreferencesrequest, preference.v1_0.getpreferencesresponse, preference.v1_0.isaliveresponse, preference.v1_0.preference, preference.v1_0.setpreferencesrequest, preference.v1_0.setpreferencesrequest > preference.v1.0.setpreferencesrequest, preference.v1_0.setpreferencesresponse, preferences.v1]]
[1/20/17 16:21:52:072 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext Following packages are in this batch of getJAXBContext() :
[1/20/17 16:21:52:073 EST] 000001aa JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils getJAXBContext @preference.v1
我正在研究一下,发现不正确的JAXB标记可能是个问题,所以下面是这个事务中使用的类。如果我需要包含任何其他课程,请告诉我。
Preference.java
@WebServiceClient(name = "Preference", targetNamespace = "http://someurl.com/preference/v1.0/", wsdlLocation = "/META-INF/wsdl/Preference.wsdl")
public class Preference
extends Service
{
@WebEndpoint(name = "PreferenceSoap")
public PreferenceSoap getPreferenceSoap() {
return super.getPort(new QName("http://someurl.com/preference/v1.0/", "PreferenceSoap"), PreferenceSoap.class);
}
}
PreferenceSoap.java
@WebService(name = "PreferenceSoap", targetNamespace = "http://someurl.com/preference/v1.0/")
@XmlSeeAlso({
preference.v1.ObjectFactory.class,
preference.v1_0.commonheadertypes.ObjectFactory.class,
preference.v1_0.filterheader.ObjectFactory.class,
preference.v1_0.filterheaderresponse.ObjectFactory.class,
preference.v1_0.getfilterheaderrequest.ObjectFactory.class,
preference.v1_0.getpreferencesrequest.ObjectFactory.class,
preference.v1_0.getpreferencesresponse.ObjectFactory.class,
preference.v1_0.isaliveresponse.ObjectFactory.class,
preference.v1_0.preference.ObjectFactory.class,
preference.v1_0.setpreferencesrequest.ObjectFactory.class,
preference.v1_0.setpreferencesresponse.ObjectFactory.class
})
public interface PreferenceSoap {
/**
*
* @param getFilterHeaderRequest
* @return
* returns preference.v1_0.filterheaderresponse.FilterHeaderResponse
*/
@WebMethod(operationName = "GetFilterHeaders", action = "http://someurl.com/preference/v1.0/GetFilterHeaders")
@WebResult(name = "GetFilterHeadersResult", targetNamespace = "http://someurl.com/preference/v1.0/")
@RequestWrapper(localName = "GetFilterHeaders", targetNamespace = "http://someurl.com/preference/v1.0/", className = "preference.v1.GetFilterHeaders")
@ResponseWrapper(localName = "GetFilterHeadersResponse", targetNamespace = "http://someurl.com/preference/v1.0/", className = "preference.v1.GetFilterHeadersResponse")
public FilterHeaderResponse getFilterHeaders(
@WebParam(name = "RequestHeader", targetNamespace = "http://someurl.com/preferences/v1.0/", header = true)
RequestHeader requestHeader,
@WebParam(name = "getFilterHeaderRequest", targetNamespace = "http://someurl.com/preference/v1.0/")
GetFilterHeaderRequest getFilterHeaderRequest);
}
GetFilterHeadersResponse.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"getFilterHeadersResult"
})
@XmlRootElement(name = "GetFilterHeadersResponse")
public class GetFilterHeadersResponse {
@XmlElement(name = "GetFilterHeadersResult")
protected FilterHeaderResponse getFilterHeadersResult;
/**
* Gets the value of the getFilterHeadersResult property.
*
* @return
* possible object is
* {@link FilterHeaderResponse }
*
*/
public FilterHeaderResponse getGetFilterHeadersResult() {
return getFilterHeadersResult;
}
/**
* Sets the value of the getFilterHeadersResult property.
*
* @param value
* allowed object is
* {@link FilterHeaderResponse }
*
*/
public void setGetFilterHeadersResult(FilterHeaderResponse value) {
this.getFilterHeadersResult = value;
}
}
filterheaderresponse.ObjectFactory.java
package preference.v1_0.filterheaderresponse;
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: preference.v1_0.filterheaderresponse
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link FilterHeaderResponse }
*
*/
public FilterHeaderResponse createFilterHeaderResponse() {
return new FilterHeaderResponse();
}
/**
* Create an instance of {@link ArrayOfFilterHeader }
*
*/
public ArrayOfFilterHeader createArrayOfFilterHeader() {
return new ArrayOfFilterHeader();
}
}
在这一切中我是否缺少某些东西?当我在本地针对通用IBM JAX-WS瘦客户端运行它时,它工作得很好,所以我需要在WebSphere中进行一些额外的配置设置才能使其工作吗?另外,为什么它能够为请求构建适当的上下文而不是响应?
答案 0 :(得分:0)
两台服务器都是WAS 8.5.5服务器吗?也许它在jaxblibrary版本中有所不同?例如,JAXB 2.1 vs 2.2?