c# ebay api, works on W7 but not on xp - c#

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!

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.

Related

Access Sharepoint documents from .NET core application(bot framework version 4)

I am using C# (.NET Core) with Bot Framework v4 to develop a bot service. I am a beginner to Bot Framework.
The problem statement is as follows:
- Give thumbs up and thumbs down at the end of every message for feedback.
- When a user clicks on thumbs down, fetch the related documents from Sharepoint.
- Display the list of fetched docs as a carousel in the chat window.
I was able to do this using the version 3 .NET SDK. However, I have trouble replicating it in version 4 of the framework - we do not have SharePoint CSOm NuGet package available for .NET Core. hence added the dlls as suggested in https://rajujoseph.com/getting-net-core-and-sharepoint-csom-play-nice/
public static async Task<List<SearchContent>> SearchContent(string queryText, short resultCount)
{
List<SearchContent> searchResult = new List<SearchContent>();
string SiteUrl = "https:--";
try
{
using (ClientContext clientContext = new ClientContext(SiteUrl))
{
// AccessPolicyEntry ape= getAccessPolicies();
if (SpUserName == string.Empty || SpUserPass == string.Empty)
{
await GetKeyVaultSecret();
}
SecureString securePassword = GetSecureString(SpUserPass);
clientContext.Credentials = new SharePointOnlineCredentials(SpUserName, securePassword);
KeywordQuery keywordQuery = new KeywordQuery(clientContext);
keywordQuery.RowLimit = 5;
keywordQuery.SummaryLength = 3000;
keywordQuery.QueryText = queryText + " site:\"https://----/Deploy\"";
SearchExecutor searchExecutor = new SearchExecutor(clientContext);
ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
clientContext.ExecuteQuery();
short counter = 0;
foreach (var oResultRow in results.Value[0].ResultRows)
{
if (counter < resultCount)
{
counter++;
string optimizeSummary = OptimizeContent(queryText, oResultRow["HitHighlightedSummary"].ToString());
searchResult.Add(new SearchContent() { Title = oResultRow["Title"].ToString(), Summery = optimizeSummary, Path = oResultRow["Path"].ToString() });
}
else
{
break;
}
}
}
}
catch (Exception ex)
{
searchResult = null;
ExceptionUtility.LogException(ex, "SharePointSearchService.SearchContent");
}
return searchResult;
}
Use Microsoft.SharePoint.Client.Runtime.Portable.dll not Microsoft.SharePoint.Client.Runtime.Windows.dll. In SharePoint CSOM projects you must always have both the Client and Client.Runtime assemblies (and they should match).

C# Interops error running MS ACCESS macros

I developed a command line app in C# that runs some macros in MS ACCESS but I am getting the following error in the production environment:
System.Runtime.InteropServices.COMException (0x800A09B6): You can´t carry out this action at the present time.
at Microsoft.Office.Interop.Access.DoCmd.RunMacro(Object MacroName, Object RepeatCount, Object RepeatExpression)
When I run the application again it works fine.
This is the code:
public void RunMacros()
{
Application access = null;
_runningMacros = true;
CloseMessageBox("Microsoft Access"); // Thread to close MsgBoxes
try
{
access = new Application();
access.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow;
var databases = MdbSettings.Config.Databases;
for (var mdbIndex = 0; mdbIndex < databases.Count; mdbIndex++)
{
if (databases[mdbIndex].Type == ReportType)
{
var mdbFile = databases[mdbIndex].File;
if (mdbFile.StartsWith("OcnTs*", StringComparison.InvariantCultureIgnoreCase))
{
mdbFile = mdbFile.Replace("*", Settings.DateReplaceName);
}
var mdbFullPath = GetFileFullPath(mdbFile, MdbPath);
access.OpenCurrentDatabase(mdbFullPath, Settings.IsDbExclusive);
for (var macrosIndex = 0; macrosIndex < databases[mdbIndex].Macros.Count; macrosIndex++)
{
var macro = databases[mdbIndex].Macros[macrosIndex].Name;
var message = string.Format("{0}, macro: {1}", Path.GetFileName(mdbFullPath), macro);
Log.Write(message);
access.DoCmd.RunMacro(macro);
}
access.CloseCurrentDatabase();
}
}
_runningMacros = false;
access.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveNone);
Marshal.ReleaseComObject(access);
access = null;
}
catch (Exception ex)
{
Log.Write(ex.ToString());
try
{
Marshal.ReleaseComObject(access);
}
catch (Exception e)
{
Log.Write("Error realeasing Access application: " + e.ToString(), Log.Severity.Warning);
}
throw;
}
}
Can someone help me to fix the error?
EDITED:
- The error only occurs in production environment
- The production environment has installed MS Access 2010
- The development environment has installed MS Access 2016
- Every macro run between 6 and 20 queries
- The error does not always occur in the same macro

Bloomberg web service call for single field and single instrument taking more than 1 min

I am making a Bloomberg web service GetData call for the "DEBT_TO_EQUITY_FUNDAMENTALS_TKR" field. I am setting secmaster = true and asking for a single instrument with a CUSIP identifier (with yellowkey = MarketSector.Corp).
This strikes me as a fairly lightweight call having seen people asking for thousands of instruments and dozens of fields at once.
I have played around with setting lots of different settings but I just can't get this request to return in a few seconds. It gives me the correct return value but it takes longer than 60 seconds.
Any idea if it is possible to get such a request to execute and return in a few seconds?
Thanks
EDIT - Here is the code I am running:
public string GetFundamentalTicker(string identifier, InstrumentType identifierType = InstrumentType.CUSIP)
{
PerSecurityWS ps = new PerSecurityWS();
try
{
log.DebugFormat("Cert path is: {0}", CertPath);
X509Certificate2 clientCert = new X509Certificate2(CertPath, "<password_redacted>");
ps.ClientCertificates.Add(clientCert);
}
catch (Exception e)
{
log.ErrorFormat("Error in cert setup - {0} - {1}", e.Message, e.InnerException == null ? "" : e.InnerException.Message);
return null;
}
//Set request header
GetDataHeaders getDataHeaders = new GetDataHeaders();
getDataHeaders.secmaster = true;
getDataHeaders.secmasterSpecified = true;
//getDataHeaders.fundamentals = true;
//getDataHeaders.fundamentalsSpecified = true;
//getDataHeaders.programflag = ProgramFlag.oneshot;//unnecessary - defaults to this anyway
//getDataHeaders.programflagSpecified = true;
//getDataHeaders.pricing = true;
getDataHeaders.secid = identifierType;
getDataHeaders.secidSpecified = true;
SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest();
sbmtGtDtreq.headers = getDataHeaders;
sbmtGtDtreq.fields = new string[] {
"DEBT_TO_EQUITY_FUNDAMENTALS_TKR"
};
int currentFundYear = DateTime.Now.Year;
//var fundYears = new List<int>();
List<Instrument> fundYearInstruments = new List<Instrument>();
Instrument fundYearInstrument = null;
fundYearInstrument = new Instrument();
fundYearInstrument.id = identifier;
fundYearInstrument.typeSpecified = true;
fundYearInstrument.type = identifierType;
fundYearInstrument.yellowkey = MarketSector.Corp;
fundYearInstrument.yellowkeySpecified = true;
//fundYearInstrument.overrides = new Override[] {};//{ new Override() { field = "EQY_FUND_YEAR", value = currentFundYear.ToString() } };
fundYearInstruments.Add(fundYearInstrument);
//fundYears.Add(-1);
Instrument[] instr = fundYearInstruments.ToArray();
Instruments instrs = new Instruments();
instrs.instrument = instr;
sbmtGtDtreq.instruments = instrs;
try
{
SubmitGetDataResponse sbmtGtDtResp = ps.submitGetDataRequest(sbmtGtDtreq);
RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest();
rtrvGtDrReq.responseId = sbmtGtDtResp.responseId;
RetrieveGetDataResponse rtrvGtDrResp;
do
{
System.Threading.Thread.Sleep(POLL_INTERVAL);
rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq);
}
while (rtrvGtDrResp.statusCode.code == DATA_NOT_AVAILABLE);
if (rtrvGtDrResp.statusCode.code == SUCCESS)
{
for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++)
{
for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++)
{
if (rtrvGtDrResp.instrumentDatas[i].data[j].value == "N.A." || rtrvGtDrResp.instrumentDatas[i].data[j].value == "N.S." || rtrvGtDrResp.instrumentDatas[i].data[j].value == "N.D.")
rtrvGtDrResp.instrumentDatas[i].data[j].value = null;
return rtrvGtDrResp.instrumentDatas[i].data[j].value;
}
}
return null;
}
else if (rtrvGtDrResp.statusCode.code == REQUEST_ERROR)
{
log.ErrorFormat("Error in the submitted request: {0}", rtrvGtDrResp.statusCode.description);
return null;
}
}
catch (Exception e)
{
log.ErrorFormat("Error in GetData - {0} - {1}", e.Message, e.InnerException == null ? "" : e.InnerException.Message);
return null;
}
return null;
}
Poll interval is 5 seconds and the SOAP web service url is:
https://software.bloomberg.com/datalicensewp/dlws.wsdl
I am having the same issue. I found out that there is a difference between making the same call to Bloomberg API from, for example, console app (works very fast) and web service (takes a lot of time to start session). And the difference is that console app runs under the same user as bbcomm process, whereas web service (or actually iis process) runs under System account. You can try to log out all users on the PC where web service is hosted and then try to make the call. In this case, I guess, bbcomm goes under System account as no one else is logged in and works fast. It worked for me and the call was answered instantly.

PayPal Express Checkout in asp.net

i am usning below web service for implement express checkout
//Demo
https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl
//Live
https://www.paypal.com/wsdl/PayPalSvc.wsdl
i took help from belo blog URL.
http://blog.effectlabs.com/post/2011/11/07/Paypal-Express-Checkout-with-C-using-Paypal-web-services.aspx
error is -in response object i am getting " resp.Token is null " when i run same code on xp-64 bit (port and iis6 both),window server 2008 (iis7 32 bit mode)
But running fine(no error, token is nut null getting value in that) on win-7 32 bit iis7 and port
my code is below.
protected void btnPaypal_Click(object sender, EventArgs e)
{
CustomSecurityHeaderType type = new CustomSecurityHeaderType();
type.Credentials = new UserIdPasswordType()
{
Username = "removed",
Password = "removed",
Signature = "removed"
};
SetExpressCheckoutRequestDetailsType sdt = new SetExpressCheckoutRequestDetailsType();
sdt.NoShipping = "1";
PaymentDetailsType pdt = new PaymentDetailsType()
{
OrderDescription = "Payment Details Sushant",
OrderTotal = new BasicAmountType()
{
currencyID = CurrencyCodeType.USD,
Value = "100.00"
}
};
sdt.PaymentDetails = new PaymentDetailsType[] { pdt };
sdt.CancelURL = "http://localhost/OAT/Default.aspx";
sdt.ReturnURL = "http://localhost/OAT/ExpressCheckoutSuccess.aspx";
SetExpressCheckoutReq req = new SetExpressCheckoutReq()
{
SetExpressCheckoutRequest = new SetExpressCheckoutRequestType()
{
SetExpressCheckoutRequestDetails = sdt,
Version = "60.0"
}
};
PayPalAPIAAInterfaceClient paypalAAInt = new PayPalAPIAAInterfaceClient();
var resp = paypalAAInt.SetExpressCheckout(ref type, req);
if (resp.Errors != null && resp.Errors.Length > 0)
{
// errors occured
throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
resp.Errors[0].LongMessage + resp.Errors.Length.ToString());
}
// error is here.. that resp.Token is null on xp-64 bit port and iis6 both, but running fine on win-7 32 bit iis7 and port, and w
Response.Redirect(string.Format("{0}?cmd=_express-checkout&token={1}",
"https://www.paypal.com/cgi-bin/webscr", resp.Token));
}
In the folder for PayPal Web Reference open the Reference.cs file in a text editor and search for "System.Xml.XmlElement Any"
You will notice code like:
[System.Xml.Serialization.XmlElementAttribute(Order=6)]
public System.Xml.XmlElement Any {
get {
return this.anyField;
}
set {
this.anyField = value;
this.RaisePropertyChanged("Any");
}
}
Now replace
[System.Xml.Serialization.XmlElementAttribute(Order=6)]
with
[System.Xml.Serialization.XmlIgnoreAttribute()]
and run your application after recompiling.
You will now see resp.Token as populated with the required value

How to use the Microsoft Translator API over Windows Azure, for Windows Phone?

Previously there the bing translator was easily accessible with the SOAP interface. Now it has been migrated to Windows Azure. I have registered in the Azure marketplace for 10000 letters per month (free). How can I translate text through the translator api, for windows phone in C#? Please help. I am not sure how to use the BeginExecute and EndExecute for queries.
I have downloaded and added the TranslatorContainer.cs to my project. For now I am just trying to get the Languages with the GetLanguagesForTranslation method. This is the code which I have written.
public partial class PhonePage1 : PhoneApplicationPage
{
public PhonePage1()
{
InitializeComponent();
Translator transInstance = new Translator();
}
class Translator
{
private Uri service_root;
private TranslatorContainer context;
public Translator()
{
service_root = new Uri("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/");
context = new TranslatorContainer(service_root);
context.Credentials = new NetworkCredential("ID","...........");
var query = context.GetLanguagesForTranslation();
query.BeginExecute(OnQueryComplete, query);
}
public void OnQueryComplete(IAsyncResult result)
{
var query = result as DataServiceQuery<Language>;
string langstring = "";
foreach (Language lang in query.EndExecute(result))
{
langstring += lang.Code + "\n";
}
MessageBox.Show(langstring);
}
}
}
In OnQueryComplete() the query is null even after the assignment. The result has the Properties IsCompleted as true, and statusCode is OK.
I am not able to figure out how to go about this. Please help.
Thank you
With help from Bing Translator team I got it working in my Silverlight Application:
UseDefaultCredentials needs to be turned off on the proxy
On the async callback, you were casting the result to a DSQ, but it’s the result’s AsyncState that needs to be casted. See below.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var serviceUri = new Uri("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/");
var accountKey = "**********************"; //
var tcode = new Microsoft.TranslatorContainer(serviceUri);
tcode.Credentials = new NetworkCredential(accountKey, accountKey);
tcode.UseDefaultCredentials = false;
var query = tcode.GetLanguagesForTranslation();
query.BeginExecute(OnQueryComplete, query);
}
public void OnQueryComplete(IAsyncResult result)
{
var query = (DataServiceQuery<Microsoft.Language>)result.AsyncState;
var enumerableLanguages = query.EndExecute(result);
string langstring = "";
foreach (Microsoft.Language lang in enumerableLanguages)
{
langstring += lang.Code + "\n";
}
MessageBox.Show(langstring);
}
This way you can use BeginExecute() and BeginEnd() to get Async results.
I had exact same problem and I was suggested that the issue may be related with the how the Async results are return internally when calling GetLanguagesForTranslation, however I did not dig further and just used Execute() to get the list of Language as below:
var serviceUri = new Uri("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/");
var accountKey = "***********************"; //
var tcode = new TranslatorContainer(serviceUri);
tcode.Credentials = new NetworkCredential(accountKey, accountKey);
var languages = tcode.GetLanguagesForTranslation().Execute().ToArray();
foreach (var i in languages)
{
Console.WriteLine(i.Code);
}
Not sure if that is what you are looking for but it worked in my case well.

Categories

Resources