我正在尝试从Java访问MicroSoft Dynamic CRM 2011在线网络服务但到目前为止没有运气。
我得到了组织WSDL文件,并在Axis2(wsdl2Java)的帮助下生成了所需的java存根文件。
我的简单客户端代码是
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
我的客户端代码中是否有任何遗漏的东西。非常感谢您的帮助。
此致
答案 0 :(得分:1)