c# ebay api,适用于 W7 但不适用于 xp
我开发了一个使用 eBay 的“finditemsAdvanced”API 调用的应用程序。 它在 Windows 7 上运行没有问题,但当我在 XP 机器上尝试时,该函数返回 null!!!!我尝试在xp、vs2010和vs 2008上调试它,但什么也没有!!!
这里是搜索类:
public SearchResult Search(Job searchedjob)
{
try
{
EbayFind service = new EbayFind();
service.Url = "http://svcs.ebay.com/services/search/FindingService/v1";
FindItemsAdvancedRequest findrequest = new FindItemsAdvancedRequest();
ItemFilter[] filtro = new ItemFilter[1];
int filter = 0;
//Tempo rimanente
filtro[filter] = new ItemFilter();
filtro[filter].name = ItemFilterType.EndTimeTo;
filtro[filter].value = new string[]
{
searchedjob.TimeLeft.ToString("yyyy-MM-ddTHH:mm:ss.000Z")
};
filter++;
findrequest.keywords = "canon";
findrequest.itemFilter = filtro;
findrequest.descriptionSearch = false;
// Setting the pagination
PaginationInput pagination = new PaginationInput();
pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 25;
pagination.pageNumberSpecified = true;
pagination.pageNumber = 1;
findrequest.paginationInput = pagination;
findrequest.paginationInput = pagination;
// Creating an object to the BestMatchService class
FindItemsAdvancedResponse resp = service.findItemsAdvanced(findrequest);
SearchResult res = resp.searchResult;
return res;
}
这里是 eBay 调用:
class EbayFind : FindingService
{
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
try
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
request.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "myappid");
request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsAdvanced");
request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "FindingService");
request.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP11");
request.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
return request;
}
catch (Exception ex)
{
throw ex;
}
}
}
此代码适用于 w7 机器,我不明白为什么“res”在 xp 上始终为空! 安装的.net框架是3.5和4.0,我认为这不是框架问题。 有什么想法吗?
谢谢!
I developed an application that use the "finditemsAdvanced" api call of ebay.
It works without problem on windows 7 but when i try it on xp machines the function returns null!!!! I tried to debug it on xp, with vs2010 and vs 2008 but nothing!!!!
here the search class:
public SearchResult Search(Job searchedjob)
{
try
{
EbayFind service = new EbayFind();
service.Url = "http://svcs.ebay.com/services/search/FindingService/v1";
FindItemsAdvancedRequest findrequest = new FindItemsAdvancedRequest();
ItemFilter[] filtro = new ItemFilter[1];
int filter = 0;
//Tempo rimanente
filtro[filter] = new ItemFilter();
filtro[filter].name = ItemFilterType.EndTimeTo;
filtro[filter].value = new string[]
{
searchedjob.TimeLeft.ToString("yyyy-MM-ddTHH:mm:ss.000Z")
};
filter++;
findrequest.keywords = "canon";
findrequest.itemFilter = filtro;
findrequest.descriptionSearch = false;
// Setting the pagination
PaginationInput pagination = new PaginationInput();
pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 25;
pagination.pageNumberSpecified = true;
pagination.pageNumber = 1;
findrequest.paginationInput = pagination;
findrequest.paginationInput = pagination;
// Creating an object to the BestMatchService class
FindItemsAdvancedResponse resp = service.findItemsAdvanced(findrequest);
SearchResult res = resp.searchResult;
return res;
}
and here the ebay call:
class EbayFind : FindingService
{
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
try
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
request.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "myappid");
request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsAdvanced");
request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "FindingService");
request.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP11");
request.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
return request;
}
catch (Exception ex)
{
throw ex;
}
}
}
This code works on w7 machines, i don't understand why "res" is always null on xp!!!
The net framework installed is 3.5 and 4.0, it's not a framework issue i think.
Any ideas??
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在黑暗中刺伤——Windows 防火墙。
尝试在调试时在控制面板中禁用它。如果有影响,请配置例外以允许来自应用程序的 api 调用通过。
Stab in the dark -- Windows Firewall.
Try disabling it in the control panel while debugging. If it makes a difference, configure an exception to allow the api calls from your application through.