2009-07-12 34 views
8

Có tài nguyên trực tuyến nào hiển thị các bước cơ bản để truy cập dịch vụ web tại chỗ của Microsoft CRM với khách hàng được viết bằng Java không?Kết nối với dịch vụ web tại chỗ của Microsoft Dynamics CRM với Java?

Tôi nên sử dụng bộ công cụ dịch vụ web nào?

Tôi đã thử với JAXB nhưng có xung đột trong việc đặt tên phần tử WSDL yêu cầu tùy chỉnh lớp. Nếu tôi tìm thấy sửa chữa ràng buộc chính xác, tôi sẽ đăng nó ở đây.

+0

Bạn đã thực hiện Ms Dynamics CRM, nếu có thì cho phép bạn hướng dẫn cho tôi để đạt được giống nhau. tìm kiếm bạn phản ứng. –

+0

@SenthilMg không, chúng tôi đã sử dụng ứng dụng khách WCF và trao đổi thông điệp dựa trên tệp đơn giản. Xem dưới đây cho một gợi ý rằng Axis 2 có thể được sử dụng. – mjn

+0

Tôi đang gặp sự cố Cần trợ giúp khắc phục lỗi, org.apache.axis2.AxisFault: Lỗi giao thông: 401 Lỗi: Không được phép tại org.apache.axis2.transport.http.HTTPSender.handleResponse (HTTPSender.java:296) tại org.apache.axis2.transport.http.HTTPSender.sendViaPost (HTTPSender.java:190) tại org.apache.axis2.transport.http.HTTPSender.send (HTTPSender.java:75) tại org.apache.axis2.transport .http.CommonsHTTPTransportSender.writeMessageWithCommo‌ ns (CommonsHTTPTransportSender.java:364) tại org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke (CommonsHTTPTra‌ nsportSender.java:208) .. –

Trả lời

8

Ứng dụng Microsoft Dynamics CRM trên phiên bản tiền đề sử dụng xác thực Active Directory. Mặc dù tôi chưa bao giờ thử tham khảo các dịch vụ web Microsoft Dynamics CRM từ Java, tôi chắc chắn nó khả thi, vì đây là các dịch vụ web chuẩn và có thể được tham chiếu từ Java qua SOAP, giống như bất kỳ dịch vụ web nào khác.

public class TestCRM { 

private static String endpointURL = "http://server:port/MSCrmServices/2007/CrmService.asmx"; 
private static String userName = "username"; 
private static String password = "password"; 
private static String host = "server"; 
private static int portport = port; 

//To make sure you are using the correct domain open ie and try to reach the service. The same domain you entered there is needed here 
private static String domain = "DOMAIN"; 

private static String orgName = "THIS_IS_REQUIRED"; //this does the work.... 


public static void main(String[] args) { 

    CrmServiceStub stub; 
    try { 
     stub = new CrmServiceStub(endpointURL); 
     setOptions(stub._getServiceClient().getOptions()); 

     RetrieveMultipleDocument rmd = RetrieveMultipleDocument.Factory.newInstance(); 
     RetrieveMultiple rm = RetrieveMultiple.Factory.newInstance(); 

     QueryExpression query = QueryExpression.Factory.newInstance(); 
     query.setColumnSet(AllColumns.Factory.newInstance()); 
     query.setEntityName(EntityName.######.toString()); 
     //query.setFilter... 

     rm.setQuery(query); 
     rmd.setRetrieveMultiple(rm); 

     //Now this is required. Without it all i got was 401s errors 
     CrmAuthenticationTokenDocument catd = CrmAuthenticationTokenDocument.Factory.newInstance(); 
     CrmAuthenticationToken token = CrmAuthenticationToken.Factory.newInstance(); 
     token.setAuthenticationType(0);  
     token.setOrganizationName(orgName); 
     catd.setCrmAuthenticationToken(token); 

     boolean fetchNext = true; 
     while(fetchNext){ 
      RetrieveMultipleResponseDocument rmrd = stub.RetrieveMultiple(rmd, catd, null, null); 
      RetrieveMultipleResponse rmr = rmrd.getRetrieveMultipleResponse(); 
      BusinessEntityCollection bec = rmr.getRetrieveMultipleResult(); 

      String pagingCookie = bec.getPagingCookie(); 
      fetchNext = bec.getMoreRecords(); 

      ArrayOfBusinessEntity aobe = bec.getBusinessEntities(); 
      BusinessEntity[] myEntitiesAtLast = aobe.getBusinessEntityArray(); 

      for(int i=0; i<myEntitiesAtLast.length; i++){ 
       //cast to whatever you asked for... 
       ### myEntity = (###) myEntitiesAtLast[i]; 
      } 
     } 
    } 
    catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

private static void setOptions(Options options){ 
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); 

    List authSchemes = new ArrayList(); 
    authSchemes.add(HttpTransportProperties.Authenticator.NTLM); 
    auth.setAuthSchemes(authSchemes); 

    auth.setUsername(userName); 
    auth.setPassword(password); 
    auth.setHost(host); 
    auth.setPort(port); 
    auth.setDomain(domain); 
    auth.setPreemptiveAuthentication(false); //it doesnt matter... 
    options.setProperty(HTTPConstants.AUTHENTICATE, auth); 
    options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true"); //i think this is good.. not required though 
} 
+0

Mã nguồn này có vẻ tốt, gần như chính xác như mã ví dụ C# (mà tôi đã sử dụng thành công). Bạn có biết bộ công cụ SOAP nào đã tạo ra các lớp sơ khai dịch vụ trong Java không? – mjn

+0

@ Joe, tôi đã thử đoạn trích của bạn được cung cấp ở đây nhưng kết quả không thành công, bạn có thể vui lòng cung cấp đề xuất có giá trị của bạn để triển khai CRM.Showing lỗi tại RetrieveMultipleDocument rmd = RetrieveMultipleDocument.Factory.newInstance(); –

+0

xception trong chủ đề "chính" java.lang.ExceptionInInitializerError \t tại com.microsoft.schemas.crm._2007.webservices.ExecuteDocument $ Execute $ Factory.newInstance (ExecuteDocument.java:70) \t tại javaMSCRM.Login.main (Login.java:44) Gây ra bởi: java.lang.RuntimeException: Không thể tải SchemaTypeSystem. Không thể tải lớp có tên schemaorg_apache_xmlbeans.system.s0C7B6541D611A1749D5105A4C55EC974.TypeSystemHolder. –

1

Sơ khai đã được tạo với khung công tác Apache Axis2.

0

Bạn có thể tìm thấy tài nguyên ở đây. Bạn thậm chí có thể làm việc với một ví dụ có sẵn trong Dynamics CRM SDK. Như Manuel Freiholz ​​đã nói, bạn phải sử dụng Axis2.

https://msdn.microsoft.com/en-us/library/jj602979(v=crm.5).aspx

http://blogs.msdn.com/b/dynamics-coe/archive/2013/09/21/integrating-microsoft-dynamics-crm-2011-online-with-java-and-other-non-net-clients.aspx

Ngoài ra, bạn có thể sử dụng dịch vụ web RESTful thông qua giao diện OData được cung cấp bởi Dynamics (https://msdn.microsoft.com/en-us/library/gg334279.aspx)

Các vấn đề liên quan