Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jaxb WSImport为多个Dynamics CRM 4.0 WSDL生成冲突的XmlType';s_Jaxb_Jax Ws_Dynamics Crm_Dynamics Crm 4_Wsimport - Fatal编程技术网

Jaxb WSImport为多个Dynamics CRM 4.0 WSDL生成冲突的XmlType';s

Jaxb WSImport为多个Dynamics CRM 4.0 WSDL生成冲突的XmlType';s,jaxb,jax-ws,dynamics-crm,dynamics-crm-4,wsimport,Jaxb,Jax Ws,Dynamics Crm,Dynamics Crm 4,Wsimport,我目前正在使用Dynamics CRM 4.0 Web服务。我做的第一件事是使用wsimport为Java/JAX-WS基于web服务的WSDL生成正确的类。生成类时,我遇到一些错误: [ERROR] A class/interface with the same name "com.microsoft.schemas.crm._2007.webservices.RetrieveResponse" is already in use. Use a class customization to r

我目前正在使用Dynamics CRM 4.0 Web服务。我做的第一件事是使用wsimport为
Java/JAX-WS
基于web服务的WSDL生成正确的类。生成类时,我遇到一些错误:

[ERROR] A class/interface with the same name
"com.microsoft.schemas.crm._2007.webservices.RetrieveResponse" is already in use. Use a class customization to resolve this conflict.
  line 979 of file://src/main/webapp/WEB-INF/classes/META-INF/wsdl/CrmServiceWsdl.wsdl

[ERROR] (Relevant to above error) another "RetrieveResponse" is generated from here.
  line 12274 of file://src/main/webapp/WEB-INF/classes/META-INF/wsdl/CrmServiceWsdl.wsdl
第979行告诉我们:

<s:element name="RetrieveResponse">
    <s:complexType>
      <s:sequence>
        <s:element name="RetrieveResult" type="s3:BusinessEntity" />
      </s:sequence>
    </s:complexType>
  </s:element>
CrmService ExecuteSense:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "response"
})
@XmlRootElement(name = "ExecuteResponse")
public class ExecuteResponse {

   @XmlElement(name = "Response")
   protected MetadataServiceResponse response;
etc...
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "response"
})
@XmlRootElement(name = "ExecuteResponse")
public class ExecuteResponse {

   @XmlElement(name = "Response", required = true)
   protected ResponseType response;
etc...
现在这个类只是一个例子(另一个例子是CrmAuthenticationToken),它几乎是另一个类的完全复制品。为了能够使用相同的类,我向CrmService类添加了一个包后缀(显示为前缀)。 因此,现在当我尝试调用CrmService时,我得到以下异常:

Two classes have the same XML type name "{http://schemas.microsoft.com/crm/2007/CoreTypes}CrmAuthenticationToken". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
    at com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken
    at public com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken *prefix*.com.microsoft.schemas.crm._2007.coretypes.ObjectFactory.createCrmAuthenticationToken()
    at *prefix*.com.microsoft.schemas.crm._2007.coretypes.ObjectFactory
this problem is related to the following location:
    at *prefix*.com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken
    at public javax.xml.bind.JAXBElement *prefix*.com.microsoft.schemas.crm._2007.webservices.ObjectFactory.createCrmAuthenticationToken(*prefix*.com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken)
    at *prefix*.com.microsoft.schemas.crm._2007.webservices.ObjectFactory
我个人认为他们在同一个包结构中使用相同名称的不同类是很奇怪的。这意味着您不能同时使用这两个Web服务

这是微软的错误,还是我这边的愚蠢错误?希望有人能帮我解决这个问题


谢谢你的时间

这是微软的不一致性加上wsimport有点难以使用

PickList和CRMAuthenticationToken听起来像是定制的数据类型,您希望它们能够在不同的服务之间重用。 您还希望某些特定于CRM的实体(例如,客户、业务或地址)能够在不同的服务之间得到重用

在微软方面,他们对不同的服务定义不同是不礼貌的。这使得很难将一个服务的答案发送到另一个服务

如果服务共享一个或多个公共模式,您可以先使用xjc编译这些模式。然后,您可以向wsimport提供一个所谓的事件文件,告诉它使用这些类,而不是生成新的类。看见这是一个相当复杂的问题,我可以根据经验告诉您,我遇到了错误JAXB-829,xjc忘记在事件文件中生成if exists属性

我要做的是,将每个wsdl编译成自己的包,并将生成的类视为简单的非智能数据传输对象。 如果我想将刚从一个服务检索到的对象发送到另一个服务,我会在两者之间进行转换。 如果这会导致非常笨拙的代码,或者如果您希望向某些实体添加逻辑,我建议您为您希望共享的实体编写自己的适当模型类,并在您希望与之一起使用的web服务包中向DTO对象和从DTO对象编写转换器

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "response"
})
@XmlRootElement(name = "ExecuteResponse")
public class ExecuteResponse {

   @XmlElement(name = "Response", required = true)
   protected ResponseType response;
etc...
Two classes have the same XML type name "{http://schemas.microsoft.com/crm/2007/CoreTypes}CrmAuthenticationToken". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
    at com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken
    at public com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken *prefix*.com.microsoft.schemas.crm._2007.coretypes.ObjectFactory.createCrmAuthenticationToken()
    at *prefix*.com.microsoft.schemas.crm._2007.coretypes.ObjectFactory
this problem is related to the following location:
    at *prefix*.com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken
    at public javax.xml.bind.JAXBElement *prefix*.com.microsoft.schemas.crm._2007.webservices.ObjectFactory.createCrmAuthenticationToken(*prefix*.com.microsoft.schemas.crm._2007.coretypes.CrmAuthenticationToken)
    at *prefix*.com.microsoft.schemas.crm._2007.webservices.ObjectFactory