1

有谁知道我如何处理来自 Maximo Query Web 服务的 Maximo 响应?

我能够从 Maximo 获取数据集响应,但是当我尝试获取工作订单属性(例如WONUMSITEID)时,所有属性都返回为null.

以下是我正在使用的代码,不胜感激。

       MXWO_WORKORDERType wo_add = new MXWO_WORKORDERType();

        MXWO_WORKORDERType[] wo_results;

        DateTime creationDateTime = new DateTime();
        bool creationDateTimeSpecified = false;
        string language = "NoDef";
        string transLanguage = "NoDef";
        string messageID = "NoDef";
        string maximoVersion = "NoDef";
        bool uniqueResult = false;
        string maxItems = "10000";
        string rsStart = "0";
        string rsCount = "NoDef";
        string rsTotal = "NoDef";

        MXStringType mxstringStID = new MXStringType();
        MXStringType mxstringstatus = new MXStringType();
        MXStringType mxstringwonum = new MXStringType();



        // create query from string 
        MXWOQueryType query = new MXWOQueryType();

        query.WHERE = ("SITEID = 'ABC' AND STATUS='WAPPR'");



         MXWOPortTypeClient c = new MXWOPortTypeClient("MXWOSOAP1Port");



        // perform query 


        MXWO_WORKORDERType[] returnedWOs = c.QueryMXWO(query, ref creationDateTime, ref language, ref transLanguage, ref messageID, ref maximoVersion, uniqueResult, maxItems, ref rsStart, out rsCount, out rsTotal);            

       MXWO_WORKORDERType wo = null;



       for (int i = 0; i < returnedWOs.Length; i++)
       {



           mxstringwonum.Value = returnedWOs[i].WONUM.Value;

           wo.WONUM = mxstringwonum;


           MessageBox.Show(mxstringwonum.Value);



       }
4

2 回答 2

2

检查这个

 MXWO proxy = new MXWO();
        MXWO_WORKORDERType[] wo_results;
        MXWO_WORKORDERType[] wo_new = new MXWO_WORKORDERType[1];
        DateTime creationDateTime = new DateTime();
        WebServiceUseCases.com.cts.ctsinpunvemscoe_MXWO.MXStringQueryType[] queryName = new com.cts.ctsinpunvemscoe_MXWO.MXStringQueryType[1];
        queryName[0] = new com.cts.ctsinpunvemscoe_MXWO.MXStringQueryType();
        queryName[0].Value = "";
        WebServiceUseCases.com.cts.ctsinpunvemscoe_MXWO.MXDomainQueryType[] queryStatus = new com.cts.ctsinpunvemscoe_MXWO.MXDomainQueryType[1];
        queryStatus[0] = new com.cts.ctsinpunvemscoe_MXWO.MXDomainQueryType();
        queryStatus[0].Value = "";
        MXWOQueryType query = new MXWOQueryType();
        query.WORKORDER = new MXWOQueryTypeWORKORDER();
        if (txtBoxWOName.Text != "")
        {
            queryName[0].Value = txtBoxWOName.Text;
            query.WORKORDER.WONUM = queryName;
        }
        if (cmBoxStatus.SelectedIndex != 0)
        {
            queryStatus[0].Value = cmBoxStatus.SelectedItem.ToString();
            query.WORKORDER.STATUS = queryStatus;
        }

        proxy.Url = "http://<server name>:<port>/meaweb/services/MXWO";

        bool creationDateTimeSpecified = false;
        string language = "en";
        string transLanguage = "en";
        string messageID = "NoDef";
        string maximoVersion = "NoDef";
        bool uniqueResult = false;
        string maxItems = "2000";
        string rsStart = "0";
        string rsCount = "NoDef";
        string rsTotal = "NoDef";

        wo_results = proxy.QueryMXWO(query, ref creationDateTime, ref creationDateTimeSpecified, ref language,
        ref transLanguage, ref messageID, ref maximoVersion, uniqueResult, maxItems, ref rsStart, out rsCount, out rsTotal);
于 2013-11-14T10:19:00.517 回答
1

谢谢施莱尤斯。我从其他文章中调整了您的代码和代码并使其正常工作。下面是最终代码。感谢您的回复/帮助。

        DateTime creationDateTime = new DateTime();
        bool creationDateTimeSpecified = false;
        string language = "NoDef";
        string transLanguage = "NoDef";
        string messageID = "NoDef";
        string maximoVersion = "NoDef";
        bool uniqueResult = false;
        string maxItems = "10000";
        string rsStart = "0";
        string rsCount = "NoDef";
        string rsTotal = "NoDef";

        MXStringType mxstringStID = new MXStringType();
        MXStringType mxstringwonum = new MXStringType();
        MXStringType mxDescription = new MXStringType();


        Uri serviceUri = new Uri("http://maximourl/meaweb/services/testservice");           
        BasicHttpBinding serviceBinding = new BasicHttpBinding();
        EndpointAddress EndPoint = new EndpointAddress(serviceUri);

        ChannelFactory<MXWOPortTypeChannel> channelFactory = new ChannelFactory<MXWOPortTypeChannel>(serviceBinding, EndPoint);

        //Create a channel 
        MXWOPortTypeChannel channel = channelFactory.CreateChannel();

        channel.Open();

        MXWOQueryType query1 = new MXWOQueryType();

        query1.WHERE = ("SITEID = 'ABC' AND STATUS='APPR'");


        QueryMXWOResponse resp1 = new QueryMXWOResponse();



        QueryMXWORequest creq = new QueryMXWORequest();

        creq.baseLanguage = language;
        //creq.creationDateTime = creationDateTime;
        creq.maximoVersion = maximoVersion;
        creq.transLanguage = transLanguage;
        creq.messageID = messageID;
        creq.rsStart = rsStart;
        creq.maxItems = maxItems;
        creq.uniqueResult = uniqueResult;

        creq.MXWOQuery = query1;


        resp1 = channel.QueryMXWO(creq);

        MXWO_WORKORDERType[] results = resp1.MXWOSet;



        for (int i = 0; i < results.Length; i++)
        {

            MXWO_WORKORDERType wt = results[i];

            mxstringwonum.Value = results[i].WONUM.Value;
            wt.WONUM.Value = mxstringwonum.Value;

            mxDescription.Value = results[i].DESCRIPTION.Value;
            wt.DESCRIPTION.Value = mxDescription.Value;

            mxstringStID.Value = results[i].SITEID.Value;
            wt.SITEID.Value = mxstringStID.Value;


           MessageBox.Show(mxstringStID.Value + " -- " + mxstringwonum.Value + " -- " + mxDescription.Value);

      }
于 2013-11-15T16:19:32.050 回答