Hi All,
Ive got a webservice which takes two inputs - currency string and value integer, looks up some values from an SPList and multiplies these by the value, basically converts an amount into different currencies. I can debug the webservice on the local machine and it works fine, however when I try from infopath I always get -
"InfoPath cannot connect to a data source" and that the query cannot be run, it does not give a particular reason why.
If I remove SPList from the webservice, it seems to work ok, any ideas?
Code for the webservice is below.
Thanks,
Alex
[WebMethod]
public decimal SalesTransactConversion(string fromCurrency, int SalesValueTransact)
{
//Create a new SPsite (SharePoint Site)
SPSite site = new SPSite("http://ukhqsptest002:45697/");
//Open the Root Webs
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
//Declare our Conversion Custom List
SPList conversionlist = web.Lists["Conversion"];
//Create an SPQuery that we will use to query the list
SPQuery query = new SPQuery();
query.Query = "<Where><And><And><Eq><FieldRef Name='Title' /><Value Type='Text'>EUR</Value></Eq>" +
"<Leq><FieldRef Name='Effective_x0020_From' /><Value Type='DateTime'>2008-07-25T00:00:00Z</Value>" +
"</Leq></And><Geq><FieldRef Name='Effective_x0020_To' /><Value Type='DateTime'>2008-07-25T00:00:00Z</Value>" +
"</Geq></And></Where>";
//Get all items in the list matching our query and put them into a collection
SPListItemCollection items = conversionlist.GetItems(query);
//Declare our Conversion Rate and Round Amount Variables
string convertratestring;
string roundvaluestring;
//Set it to a Sample Value
convertratestring = "Something";
roundvaluestring = "Something";
//Iterate through the items in the collection and set our string to the Convert Rate of the item and our Round Amount
foreach (SPListItem item in items)
{
convertratestring = item["Convert Rate"].ToString();
roundvaluestring = item["Round Value"].ToString();
}
//Convert the Conversion Rate from string to decimal
decimal convertratedecimal;
convertratedecimal = Convert.ToDecimal(convertratestring);
//Convert the Round Value from string to integer
int roundvalue;
roundvalue = Convert.ToInt16(roundvaluestring);
//Convert our Sales Value Transaction amount into a decimal
decimal SalesValueTransactdec;
SalesValueTransactdec = Convert.ToDecimal(SalesValueTransact);
//Create a decimal in which to store our Sales Value Base amount
decimal SalesValueBasedec;
//Multiple the Sales Transaction amount by the Convert Rate and return the Sales Value Base Amount
SalesValueBasedec = decimal.Multiply(SalesValueTransactdec, convertratedecimal);
//Round the Sales Value Base Amount to the Required Round Value
SalesValueBasedec = decimal.Round(SalesValueBasedec, roundvalue);
//Return the Sales Value Base Amount
return test;
My New SharePoint Blog - http://sharepointcoding.wordpress.com
MCP: Windows XP