2012-05-09 2 views
9

현재 Dynamics CRM 4.0 웹 서비스로 작업하고 있습니다. 내가 한 첫 번째 일은 Java/JAX-WS에 대한 wsimport를 사용하여 웹 서비스의 WSDL을 기반으로 올바른 클래스를 생성하는 것이 었습니다.WSImport가 여러 Dynamics CRM 4.0 WSDL의 충돌하는 XMLTypes를 생성합니다.

[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> 

그리고 라인 12,274 것은 우리에게 제공합니다

<s:complexType name="RetrieveResponse"> 
    <s:complexContent mixed="false"> 
     <s:extension base="tns:Response"> 
     <s:sequence> 
      <s:element ref="s3:BusinessEntity" /> 
     </s:sequence> 
     </s:extension> 
    </s:complexContent> 
    </s:complexType> 

두 부분 모두가 같은 네임 스페이스에 있습니다. 둘 다 RetrieveResponse.class로 생성되어 충돌합니다. 나는 JAX-B 바인딩 XML 파일이 문제에 대한 해결책을 발견했습니다 :이 작동

<bindings node="//xsd:complexType[@name='RetrieveResponse']"> 
    <jaxb:class name="RetrieveResponseType"/> 
</bindings> 

을 (확실하지 않은이 올바른 접근 방식 인 경우 ..?) ..이 후 그래서

, 나는 성공적으로 webservice에 대한 호출을 성공적으로 만들었습니다.

다이나믹스 CRM의 일부 비즈니스 엔티티는 픽리스트을 사용합니다. 이 유형의 엔티티는 메타 데이터 서비스로 질의 할 수 있습니다. http://msdn.microsoft.com/en-us/library/bb890248.aspx

다음으로 내가 한 일은 WSDL을 기반으로 메타 데이터 서비스의 클래스를 생성하는 것입니다. 생성 된 클래스의 결과는 예외는 아닙니다. 예를 들어 'com.microsoft.schemas.crm._2007.webservices.ExecuteResponse'클래스를 생성합니다. 그러나이 클래스는 CrmService 생성 클래스와 완전히 동일한 패키지에도 있습니다. 2의 차이점은 다음과

Metadataservice ExecuteReponse :

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

    @XmlElement(name = "Response") 
    protected MetadataServiceResponse response; 
etc... 

CrmService ExecuteReponse :

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

    @XmlElement(name = "Response", required = true) 
    protected ResponseType response; 
etc... 

지금이 클래스는 단지 하나의 일례 인 있다 (다른 예 CrmAuthenticationToken이다) 거의 다른 클래스의 정확한 중복. 동일한 클래스를 사용할 수 있도록 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 

내가 개인적으로는 동일한 패키지 구조에 같은 이름을 가진 다른 클래스를 넣어 이상한 생각 : 나는 CrmService를 호출 할 때 은 그래서 지금, 나는 다음과 같은 예외를 얻을. 이것은 당신이 동시에 2 개의 웹 서비스를 사용할 수 없다는 것을 의미합니다 ..

이것은 마이크로 소프트, WSimport 버그입니까, 아니면 제 마지막으로 어리석은 실수입니까? 누군가가이 문제를 도와 줄 수 있기를 바랍니다.

시간 내 주셔서 감사합니다.

답변

1

이것은 Microsoft의 불일치와 wsimport를 다소 사용하기가 어려워졌습니다.

PickList와 CRMAuthenticationToken이 사용자 지정 데이터 형식처럼 들리는 경우 서비스에서 서비스로 다시 사용하게 될 것으로 예상됩니다. 특정 CRM 관련 엔터티 (예 : 고객 또는 비즈니스 또는 주소)가 서비스에서 서비스로 다시 사용되기를 기대할 수도 있습니다.

Microsoft 측에서 서비스별로 다르게 정의하는 것은 좋지 않은 매너입니다. 따라서 한 서비스에 대한 응답을 다른 서비스로 보내기가 어렵습니다.

서비스가 하나 이상의 공용 스키마를 공유했다면 xjc를 사용하여 서비스를 컴파일 할 수있었습니다. 그런 다음 wsimport에 새로운 에피소드 파일을 제공하여 새로운 클래스를 생성하는 대신 해당 클래스를 사용하도록 지시 할 수 있습니다. the metro guide을 참조하십시오. 이것은 꽤 수수께끼인데, 경험으로 말하면, JAXB-829로 들어갔다. xjc는 if-exists 속성을 에피소드 파일에 생성하는 것을 잊어 버렸다.

내가해야 할 일은 각 wsdl을 자체 패키지로 컴파일하고 생성 된 클래스를 단순한 지능형 데이터 전송 객체로 취급합니다. 개체를 보내려는 경우 한 서비스에서 가져온 서비스를 두 번째 서비스로 가져 오면 둘 사이를 변환 할 수 있습니다. 결과적으로 다루기 힘든 코드가 발생하거나 특정 엔티티에 논리를 추가하려는 경우 웹에서 DTO 객체와 변환기를 공유하고 작성하려는 엔티티에 대한 고유 한 적절한 모델 클래스를 작성하는 것이 좋습니다 서비스 패키지를 사용할 수 있습니다.