简体   繁体   English

Exchange Web服务JAVA API(EWS-JAVA-API)

[英]Exchange Web Service JAVA API (EWS-JAVA-API)

I prepared a whole text to paste in there but since a message can't contain more than two links due to my newbiness. 我准备将整个文本粘贴到此处,但是由于消息的新颖性,一条消息不能包含两个以上的链接。 I am gonna give you a link to the original message: http://pastebin.com/bBmSc2Yb 我要给您一个原始消息的链接: http : //pastebin.com/bBmSc2Yb

Long story short, I tried to use EWS-JAVA-API on Android without any success even tough I tried this: 长话短说,我尝试在Android上使用EWS-JAVA-API并没有获得任何成功,即使尝试了也很难:

-Build EWS-JAVA-API and use it without and with distant dependencies in my Android project -build EWS-JAVA-API和使用它,而我的Android项目遥远的依赖

I tried to add same files used at compilation in the same's order as the pom.xml one. 我试图以与pom.xml相同的顺序添加用于编译的相同文件。 And I fixed conflits error by editing the build.gradle file. 我通过编辑build.gradle文件修复了错误。 Please see in the PasteBin's link to see error message. 请在PasteBin的链接中查看以查看错误消息。

-Used a remote EWS-JAVA-API (from sonartype) without and with remote dependencies from mavenCentral(). -使用远程EWS-JAVA-API(来自声纳类型), 包含 mavenCentral()和具有远程依赖关系。

-I tried alose with compiled libraires imported in local. -我尝试了用本地导入的已编译库文件进行Alose处理。

I have to access to appointements , contacts and so on. 我必须访问约会 ,联系人等。 I need to use a library which implement those functions. 我需要使用实现这些功能的库。

I am using Android Studio 1.1.0. 我正在使用Android Studio 1.1.0。 And the target version of Android is 4.3 minimum and the terminal I am using an Android 4.4.2's terminal (Samsung Galaxy S5 mini). Android的目标版本最低为4.3,并且终端使用的是Android 4.4.2的终端(三星Galaxy S5 mini)。

Does anyone manage to successly to do something with this library ? 有人能成功地使用库做什么吗?

Thanks, WMWare, 谢谢,WMWare,

I tried out the JWebService, I get it working. 我尝试了JWebService,让它正常工作。

You should use an AsyncTask (as in login activities) to make it work. 您应该使用AsyncTask(如在登录活动中一样)使其正常工作。

Don't forget to put Internet access in your manifest. 不要忘记在清单中放入Internet访问。

Here's an example's code (thanks to Rade from the support): 这是一个示例代码(感谢Rade的支持):

Hi fellow, 大家好

Thanks, WMWare, 谢谢,WMWare,

I tried out the JWebService, I get it working. 我尝试了JWebService,让它正常工作。

You should use an AsyncTask (as in login activities) to make it work. 您应该使用AsyncTask(如在登录活动中一样)使其正常工作。

Don't forget to put Internet access in your manifest. 不要忘记在清单中放入Internet访问。

Here's an example's code (thanks to Rade from the support): 这是一个示例代码(感谢Rade的支持):

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.independentsoft.exchange.Appointment;
import com.independentsoft.exchange.Body;
import com.independentsoft.exchange.Folder;
import com.independentsoft.exchange.ItemId;
import com.independentsoft.exchange.Service;
import com.independentsoft.exchange.ServiceException;
import com.independentsoft.exchange.StandardFolder;

import java.text.SimpleDateFormat;
import java.util.Date;


public class MyActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        new MyAsyncTask().execute();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
         //Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private class MyAsyncTask extends AsyncTask<String, Integer, String> {


        @Override
        protected String doInBackground(String... params) {
            // TODO Auto-generated method stub
            String s=postData(params);
            return s;
        }

        protected void onPostExecute(String result){

        }
        protected void onProgressUpdate(Integer... progress){

        }

        public String postData(String valueIWantToSend[]) {

            String returnValue = "";
            try {
                Service service = new Service("https:192.168.2.105/ews/Exchange.asmx", "John","xxxxx");

                Folder inboxFolder = service.getFolder(StandardFolder.INBOX);

                Log.w("inboxFolder", inboxFolder.getDisplayName());

                returnValue = inboxFolder.getDisplayName();

            }
            catch (ServiceException ex)
            {
                Log.w("ServiceException", ":" + ex.getFaultCode());
                Log.w("ServiceException", ":" + ex.getFaultString());
                Log.w("ServiceException", ":" + ex.getMessage());
                Log.w("ServiceException", ":" + ex.getXmlMessage());
                Log.w("ServiceException", ":" + ex.getResponseCode());
                Log.w("ServiceException", ":" + ex.getRequestBody());
            }
            catch (Exception ex)
            {
                Log.w("Exception", ex.getMessage());
            }

            return returnValue;
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM