我下载了一个示例应用程序,用于在线系统使用某些Web服务。
我不确定是否需要以下所有代码,但这是我得到的,我想要做的是使用搜索功能。
我首先使用我拥有的ID调用searchCustomer:
partnerRef.internalId = searchCustomer(customerID);
searchCustomer的代码:
private string searchCustomer(string CustomerID)
{
string InternalID = "";
CustomerSearch custSearch = new CustomerSearch();
CustomerSearchBasic custSearchBasic = new CustomerSearchBasic();
String nameValue = CustomerID;
SearchStringField entityId = null;
entityId = new SearchStringField();
entityId.@operator = SearchStringFieldOperator.contains;
entityId.operatorSpecified = true;
entityId.searchValue = nameValue;
custSearchBasic.entityId = entityId;
String statusKeysValue = "";
SearchMultiSelectField status = null;
if (statusKeysValue != null && !statusKeysValue.Trim().Equals(""))
{
status = new SearchMultiSelectField();
status.@operator = SearchMultiSelectFieldOperator.anyOf;
status.operatorSpecified = true;
string[] nskeys = statusKeysValue.Split(new Char[] { ',' });
RecordRef[] recordRefs = new RecordRef[statusKeysValue.Length];
for (int i = 0; i < nskeys.Length; i++)
{
RecordRef recordRef = new RecordRef();
recordRef.internalId = nskeys[i];
recordRefs[i] = recordRef;
}
status.searchValue = recordRefs;
custSearchBasic.entityStatus = status;
}
custSearch.basic = custSearchBasic;
SearchResult response = _service.search(custSearch);
if (response.status.isSuccess)
{
processCustomerSearchResponse(response);
if (seachMoreResult.status.isSuccess)
{
processCustomerSearchResponse(seachMoreResult);
return InternalID;
}
else
{
_out.error(getStatusDetails(seachMoreResult.status));
}
}
else
{
_out.error(getStatusDetails(response.status));
}
return InternalID;
}
在上面的代码中,processCustomerSearchResponse被调用
processCustomerSearchResponse(response);
此功能的代码是:
public string processCustomerSearchResponse(SearchResult response)
{
string InternalID = "";
Customer customer;
customer = (Customer)records[0];
InternalID = customer.internalId;
return InternalID;
}
原始代码的作用是在控制台中编写一些输出,但我想返回InternalID。当我调试应用程序时,processCustomerSearchResponse中的InternalID包含我想要的ID,但我不知道如何将它传递给searchCustomer,以便该函数也返回ID。当我调试searchCustomer时,InternalID始终为null。我不确定如何编辑response.status.isSuccess
下的代码
返回InternalID,有什么想法吗?
提前致谢。
答案 0 :(得分:1)
当您致电processCustomerSearchResponse(response);
时,您需要将返回值存储在内存中。
尝试修改您的代码:
InternalID = processCustomerSearchResponse(response);