Im new to using WCF for silverlight, could someone help me please. This is driving me mad!!
my code in service1.cs is:
[OperationContract]
public List<PublishedSoftwareItem> GetSoftwareByArea(int ID)
{
ProductionFileManager manager = new ProductionFileManager();
using (LinqToSQLPublishedSoftwareDataContext con = new LinqToSQLPublishedSoftwareDataContext())
{
var listOfSoftware = new List<PublishedSoftwareItem>();
var getSoftware = from a in con.PublishedSoftwares
join b in con.Areas on a.AreaID equals b.AreaID
join c in con.ImageDataStores on a.ImageStoreID equals c.ID
select new PublishedSoftwareItem
{
Description = a.SoftwareDescription,
PublishLink = a.PublishLink,
Title = a.SoftwareName,
SoftwareImage = manager.GetImageFromDatabase(ID)
};
listOfSoftware = getSoftware.ToList();
return listOfSoftware;
}
}
when i update my reference.cs gets messed up and the service doesnt work correctly anymore. Ive unchecked the reuse types checkbox and that didnt help. Please someone help. Ask if you need more info
you should reface this links:
WCF Service Reference and Get Use
Related
I'm trying to get a simple Acumatica contract-based SOAP API Get() or GetList() call to work and all I'm getting is an error:
System.ServiceModel.FaultException: 'System.ArgumentNullException: Value cannot be null. Parameter name: model
See the code below. I first tried the REST API, but couldn't get around different issues (which I'll also probably add in another post). Any ideas what the error is referring to?
using (var soapClient = new ServiceReference1.DefaultSoapClient())
{
//Log in to Acumatica ERP
soapClient.Login
(
"admin",
"admin",
"Company",
null,
null
);
ServiceReference1.SalesOrder orderToFind = new
ServiceReference1.SalesOrder
{
CustomerID = new ServiceReference1.StringValue { Value = "2" },
OrderType = new ServiceReference1.StringValue { Value = "SO" },
OrderNbr = new ServiceReference1.StringValue { Value =
"SO001337" },
};
var getOrder = soapClient.Get(orderToFind);
var getOrders =
soapClient.GetList(orderToFind);
}
Acumatica v17.204.0019.
Just encountered the same error and a little ashamed to admit that solution appeared to be super simply for me: the binding was simply missing allowCookies="true" in app.config
Having enabled cookies, error ArgumentNullException: Value cannot be null. Parameter name: model got resolved:
<binding name="DefaultSoap" allowCookies="true" />
The solution for me was to add the WSDL as a ServiceReference instead of a WebReference, long story. Another thing to check might be the app.config to make sure it has the correct endpoint, bindings, etc. as per Acumatica documentation.
When searching for a record, one must always work with a proper variation of the [FieldType]Search type. In your case the orderToFind object should be declared as follows:
ServiceReference1.SalesOrder orderToFind = new ServiceReference1.SalesOrder
{
OrderType = new ServiceReference1.StringSearch { Value = "SO" },
OrderNbr = new ServiceReference1.StringSearch { Value = "SO001337" }
};
var getOrder = soapClient.Get(orderToFind);
To export orders for the given customer, you should define the ordersToFind object as follows:
ServiceReference1.SalesOrder ordersToFind = new ServiceReference1.SalesOrder
{
CustomerID = new ServiceReference1.StringSearch { Value = "2" },
};
var getOrders = soapClient.GetList(orderToFind);
I have created a database with details of a car. I have to test the database using the WCF Test client. Once I input a car ID and invoke, it will not display my data from the table. Only null values. Here is my code for the service class. Why will my saved data from my table not display?
public class CarService : ICarService
{
public Car GetCar(int id)
{
CarBDO carBDO = new CarBDO();
Car car = new Car();
TranslateCarBDOToCarDTO(carBDO, car);
return car;
}
private void TranslateCarBDOToCarDTO(CarBDO carBDO, Car car)
{
car.CarID = carBDO.CarID;
car.CurrentOwner = carBDO.CurrentOwner;
car.DateFirstRegistered = carBDO.DateFirstRegistered;
car.SornStatus = carBDO.SornStatus;
car.Colour = carBDO.Colour;
car.EngineSize = carBDO.EngineSize;
car.YearofManufacture = carBDO.YearofManufacture;
car.DateTaxed = carBDO.DateTaxed;
car.Make = carBDO.Make;
car.Model = carBDO.Model;
}
I'm using wcf test client in order to test my web services. I'm pretty sure its not about wcf test client. for troubleshooting i suggest to log the values and see if they are actually null or not. then post the more detail so we can help you.
SELECT Name, ProfileId, Id, Username FROM User this is the select query to retrive data in Force.com explorer
Now I wan't to update a column how can I do this? update key word it self not working here please give the solution for this.
thanks in advance
In Salesforce you not write to update query same as in SQL.
Please use update method to update column of an object.
More information and sample please read following documents.
https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_update.htm
I found Solution it's working fine now, If any one haveing doubts ask me for Create,Update,Get functionalities
private void UpdateProfileId(string Id)
{
SforceService sfs = new SforceService();
var login = sfs.login(ConfigurationManager.AppSettings["username"],ConfigurationManager.AppSettings["password"]);
sfs.Url = login.serverUrl;
sfs.SessionHeaderValue = new SessionHeader();
sfs.SessionHeaderValue.sessionId = login.sessionId;
var userinfo = login.userInfo;
QueryResult qr = null;
sfs.QueryOptionsValue = new salesforce.QueryOptions();
User[] UpdateUser = new User[1];
User objuser = new User();
objuser.Id = Id;
objuser.ProfileId = "00e90000001CcTnAAK";
UpdateUser[0] = objuser;
try
{
SaveResult[] saveResults = sfs.update(UpdateUser);
foreach (SaveResult saveResult in saveResults)
{
if (saveResult.success)
{
Console.WriteLine("Successfully updated Account ID: " +saveResult.id);
}
}
}
}
I have the following method which is called from Ajax:
[Authorize]
[ValidateInput(false)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public JsonNetResult CreateOrUpdateTimeRecord(TimeRecord tr)
{
TimeRecord trLocal;
if (tr.Id == -1 || tr.Id == 0)
{
trLocal = new TimeRecord
{
Description = tr.Description,
StartTime = tr.StartTime,
EndTime = tr.EndTime,
User =new myTimeMvc.Models.NHibernate.Models.User {Id = tr.User.Id},// _userRepo.Get(tr.User.Id),
Hdt = new Hdt {Id = tr.Hdt.Id}//_hdtRepo.Get(tr.Hdt.Id)
};
_timeRepo.Insert(trLocal);
}
else
{
trLocal = _timeRepo.Get(tr.Id);
trLocal.Description = tr.Description;
trLocal.StartTime = tr.StartTime;
trLocal.EndTime = tr.EndTime;
_timeRepo.Update(trLocal);
}
...
}
As you can see my TimeRecord has a reference to User and Hdt. Now I started to work with NHibernate Profiler which complains when I resolve my properties by loading them from their coresponding repositories. Which is clear to me since I actually don't need to query the database for that since I have the ID's for this objects.
User = _userRepo.Get(tr.User.Id),
Hdt = _hdtRepo.Get(tr.Hdt.Id)
But I'm not 100% sure if I can use this instead:
User =new myTimeMvc.Models.NHibernate.Models.User {Id = tr.User.Id},,
Hdt = new Hdt {Id = tr.Hdt.Id}
I guess NHibernate lazy proxies work the same way since they only contain just the ID of the related object and load the rest when it is needed. Do I have to attach this "new" oject anyway to my session?
Can someone tell me what is the correct way to do this?
Cheers,
Stefan
There are a few ways how to achieve that. One of them could be using the Load() method. Check Ayendes post: NHibernate – The difference between Get, Load and querying by id, an extract:
Load will never return null. It will always return an entity or throw an exception. Because that is the contract that we have we it, it is permissible for Load to not hit the database when you call it, it is free to return a proxy instead.
Other words, we can do something like this
User = _userRepo.Load(tr.User.Id),
Hdt = _hdtRepo.Load(tr.Hdt.Id)
Where the Load would be encapsulating the session.Load()
I am developing a wcf service for Windows 8 APP. But I'm choked up at one point.
The following method, it is coming data in the database using entity. But this the data returns back to a class type. My question , if result is null what can I sent person who will this method
public AnketorDTO AnketorBul(string tc, string pass)
{
_entity = new AnketDBEntities();
var result = (from i in _entity.Anketors
where i.TC == tc
where i.Sifre == pass
select i).ToList();
if (!result.Any())
-->>> return new AnketorDTO();
Anketor anketor = result.First();
return Converter.ConvertAnketorToAnketorDTO(anketor);
}
with this methot I SENT it by creating a new class type but part which use this methot does not work because the values become null. how can we prevent it.
Client :
AnketorDTO anketor = await client.AnketorBulAsync(txtKullanici.Text, txtSifre.Password);
**if (anketor != null)
lblError.Text = anketor.Adi;**
else
lblError.Text = "Hata";
Can you try this method to see, if it works?
_entity = new AnketDBEntities();
var result = _entity.Anketors.FirstOrDefault(yourexpressions);