有谁知道如何处理来自Maximo Query Web服务的Maximo响应?
我能够从Maximo获取数据集响应,但是当我尝试获取工作订单属性(例如WONUM
,SITEID
等...)时,所有属性都返回为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);
}
答案 0 :(得分: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);
答案 1 :(得分:1)
谢谢Shreyuth。我从其他文章调整了你的代码和代码并使其正常工作。以下是最终代码。感谢您的回复/帮助。
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);
}