gpt4 book ai didi

java - 来自 Java 的 Dynamics CRM 2011 在线 Web 服务

转载 作者:行者123 更新时间:2023-12-01 15:21:48 28 4
gpt4 key购买 nike

我正在尝试从 Java 访问 MicroSoft Dynamic CRM 2011 在线 Web 服务,但到目前为止还没有成功。

我在 Axis2 (wsdl2Java) 的帮助下获得了组织 WSDL 文件并生成了所需的 java stub 文件。

我的简单客户端代码是

public class TestCRM2 {

public static void main(String[] args) {

try {

// create query
QueryExpression query = new QueryExpression();
query.setEntityName("Contact");

ArrayOfstring colAra = new ArrayOfstring();
colAra.addString("fullname");

ColumnSet columnSet = new ColumnSet();
columnSet.setAllColumns(false);
columnSet.setColumns(colAra);

PagingInfo pageinfo = new PagingInfo();
pageinfo.setCount(10);
pageinfo.setPageNumber(1);

query.setColumnSet(columnSet);
query.setPageInfo(pageinfo);

ConditionExpression condition = new ConditionExpression();
condition.setAttributeName("fullname");
condition.setOperator(ConditionOperator.Equal);

ArrayOfanyType values = new ArrayOfanyType();
values.setAnyType(new String[] {"something"});
condition.setValues(values);

RetrieveMultiple retrieveMultiple = new RetrieveMultiple();
retrieveMultiple.setQuery(query);

OrganizationServiceStub stub = new OrganizationServiceStub();

//set Timeout
ServiceClient serviceClient = stub._getServiceClient();
serviceClient.getOptions().setTimeOutInMilliSeconds( 3 * 60 * 1000);
/*serviceClient.getOptions().setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_10);
serviceClient.getOptions().setProperty(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED,false);*/

RetrieveMultipleResponse response = stub.retrieveMultiple(retrieveMultiple);

EntityCollection collection = response.getRetrieveMultipleResult();
int count = collection.getTotalRecordCount();
System.out.println(count);

} catch (Exception e) {
e.printStackTrace();
}
}}

当我从 Eclipse 运行此程序时,出现以下运行时错误

org.apache.axis2.AxisFault: Connection reset
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.microsoft.schemas.xrm._2011.contracts.OrganizationServiceStub.retrieveMultiple(OrganizationServiceStub.java:1177) at test.TestCRM.main(TestCRM.java:105)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
... 9 more

我的客户端代码中是否缺少任何内容?非常感谢您的帮助。

问候,

最佳答案

  1. 您必须在服务客户端中的端点 URL 末尾附加“/web”。
  2. 您必须提供 NTLM2 身份 validator 实现,并将其注册到您的 stub 使用的 httpclient。

关于java - 来自 Java 的 Dynamics CRM 2011 在线 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10796237/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com