AXIS2 Web Service .NET Client creates "Specified" properties - axis2

When invoking a Java AXIS2 1.6.2 web-service created using Eclipse 4.2 from visual studio 2008, The code generated of each object includes additional boolean property ending with "Specified" for all non-string parameters. Than I have to set it to Ture. Otherwise, when it hits the server the parameter is null. it's very annoying that I have to set it every time. Any way to get around it???
For example:
public Customer {
public String name {
get;
set;
}
public int? age {
get;
set;
}
public bool ageSpecified {
get;
set;
}
}

Related

Connecting and Retrieving from the SqlDatabase using SPA template

I am trying to create a SPA model which is able to create, update, delete scheduled tasks in Visual Studio 2012 using MVC4 Hottowel SPA template. Here i have a demo class which I need to use in creating database but unable to get 1) the context of the database.
2) how to configure the database in this project. I tried with creating connection using (LocalDb)\v11.0 sql server but its showing error that entity framework 6 or above is not supported with this application.
public class JobDemo
{
public string JobName { get; set; }
public string JobDescription { get; set; }
public string Frequency { get; set; }
public bool JobStatus { get; set; }
public bool JobIsActive { get; set; }
public DateTime LastModifiedOn { get; set; }
}
This is my class which I wanna use to create database of scheduled tasks/jobs and then query on them
public class DemoDb : DbContext
{
public DbSet<JobDemo> Jobject { get; set; }
public DemoDb() : base("name=DefaultConnection")
{
}
}
The class is creating the DbContext of my JobDemo Class. But after that i am unable to create database connection which use my class and use the following attributes defined in my JobDemo class.
Even though the EF6 is not supported in SPA template, the SqlServer or SqlServerCompact Database can be used with HotTowel SPA template as they support the model and can be used with Breeze Api or Simple controllers with get and post methods can be used to retrieve and store data.

ASP.NET WebApi form-urlencoded string deserialize

I develop service with WebApi and Client which send to this service gzipped data by POST method (to save bandwidth). Both of them over my control. On server I receive compressed data, decompress It and have string such as:
section[0][caption]=Foo&
section[0][address]=175896&
section[0][counters][]=2&
section[0][counters][]=2&
section[0][errors][]=ERR_NOT_AVAILABLE&
errors=true&
trmtimestamp=1346931864358
ie simple www-form-urlencoded string.
Does ASP.NET MVC4 WebApi have some method to bind or deserialize this string to my Model?
public class Snapshot
{
public List<SectionState> sections { get; set; }
public bool errors { get; set; }
public double date { get; set; }
public double trmtimestamp { get; set; }
}
You may use the following code to parse the string:
new System.Net.Http.Formatting.FormDataCollection(query).ReadAs<Snapshot>();
The ReadAs is extension method defined under System.Web.Http.ModelBinding.FormDataCollectionExtensions.

Any collection causes silent failure with 500 status code in Asp.Net MVC 4 RC Web API

I'm completely lost on what could be causing this.
I have an ASP.Net MVC 4 RC application and I have a set of Web API controllers. I'm trying to return an object that contains a set of child objects in an IList. Whenever I request the object I get a 500 error back on the browser with no noticeable exception thrown in the debugger. I've tried putting an Application_Error handler in the global.asax and no error is caught there either.
It doesn't matter whether the List is an actual database relation or just a hard coded list of strings, in either case the request fails. If i set the list to null the request succeeds.
If i remove the list the request succeeds and I get an XML (or JSON) representation of the object.
I've also tried this line -
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
To capture the actual exception and still get nothing back.
Here's the current object
public class Authority : IEntity
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual string Address1 { get; set; }
public virtual string Address2 { get; set; }
public virtual string City { get; set; }
public virtual string County { get; set; }
public virtual string State { get; set; }
public virtual string ContactPostalCode { get; set; }
//public virtual IList<PostalCode> PostalCodes { get; set; }
public virtual IList<string> RandomTrash { get; set; }
public VPA()
{
//PostalCodes = new List<PostalCode>();
RandomTrash = new List<string> {"foo"};
}
}
Note the commented out PostalCodes collection - that is a real many to many database relationship. I commented it out and replaced it with the dummy "RandomTrash" collection and the failure seems to be the same.
I have a feeling this is a serialization failure somehow but I can't figure out how to avoid it. If it helps I'm using NHibernate as the ORM.
Has anyone seen this?
Answering my own question in case anyone runs into this again.
It ended up being Serialization following the grid in a loop. To fix i added 2 attributes to each looping reference in one of the models.
[IgnoreDataMember] For the XML Serializer
[JsonIgnore] For JSON.Net's Serializer.
I added those the PostalCode class on the IList property.
There may be a better solution. The downside of this one is it makes my API one sided. I can request an Authority and get all of it's postal codes, but i can't request a postal code and get all of it's Authorities.

DTOs and WCF RIA

I have a DTO which has a collection within it of another DTO which I populate server-side and send to the client. However, this inner DTO collection is not returned to the client.
I believe I need to use the [Include] and [Association] attributes so that WCF RIA services knows what to do, however my issue with this is there is no real association as such between the main DTO and the inner DTO collection, I am just using it to aggregate data from various sources for return to the client.
Is my understanding wrong in what I am trying to achieve, if not how do I get WCF RIA to send this inner DTO collection.
I should add that I am using automapper and want to achieve it using such.
Here is an example, I want to send back to the client in one chunk;
The competencies that the employee has.
The competencies that the employee requires for their job.
The GAP, which is the difference between 1 and 2.
public class CompetencyRequirementsDto
{
[Key]
public string CompanyId { get; set; }
[Key]
public string EmployeeNo { get; set; }
public string JobId { get; set; }
[Include]
[Association("EmployeeCompetencies","CompanyId, EmployeeNo","CompanyId, EmployeeNo")]
public IList<EmployeeCompetencyDto> EmployeeCompetencies { get; set; }
[Include]
[Association("JobCompetencies","JobId, CompanyId","JobId, CompanyId")]
public IList<JobCompetencyDto> JobCompetencies { get; set; }
[Include]
[Association("CompetencyGap", "JobId, CompanyId", "JobId, CompanyId")]
public IList<JobCompetencyDto> CompetencyGap { get; set; }
} }
Now item 1 works fine, but 2 and 3 don't? What I have found is that my DTO is created ok server side but when it gets to the client CompetencyGap(even when it has no values) has
been given JobCompetencies values.
If you are using ADO.Net Entity data model and using RIA Services against them then you have got an option to create associated metadata.
So to get the reference entities at you client side we need to modify both the our corresponding meta-data and as well as well the function of the domain service class which is fetching your data .
Here I am giving an example...
1. Just add [Include] attribute at the the top of the referenced data for example.
[MetadataTypeAttribute(typeof(Customer.CustomerMetadata))]
public partial class Customer
{
// This class allows you to attach custom attributes to properties
// of the Customer class.
//
// For example, the following marks the Xyz property as a
// required property and specifies the format for valid values:
// [Required]
// [RegularExpression("[A-Z][A-Za-z0-9]*")]
// [StringLength(32)]
// public string Xyz { get; set; }
internal sealed class CustomerMetadata
{
// Metadata classes are not meant to be instantiated.
private CustomerMetadata()
{
}
public int CustomerID { get; set; }
public string EmailAddress { get; set; }
public string FullName { get; set; }
[Include]
public EntityCollection<Order> Orders { get; set; }
public string Password { get; set; }
}
}
2. Modify the function in the domain service and add include there also for example.
public IQueryable<Customer> GetCustomers()
{
var res = this.ObjectContext.Customers.Include("Orders");
return res;
}
In your case the first part is done you just need to modify your domain service query to get reference entities.

WCF client side List<>

I got a WCF service with a method (GetUserSoftware)to send a List to a client.
the software I have defined like this:
[DataContract]
public class Software
{
public string SoftwareID { get; set; }
public string SoftwareName { get; set; }
public string DownloadPath { get; set; }
public int PackageID { get; set; }
}
the method is going through my db to get all software availeble to the clien, and generates a list of that to send back to the client.
problem is i on the client side the list is turned into an array. and every item in that array dont contain any of my software attributs.
i have debugged my way through the server side. and seen that the list its about to send is correct. with the expected software and attributs in it.
any one know how to work around this or know what i can do ?
Did you forget [DataMemeber] attribute on your properties?
When you use DataContract attribute for a type you have to use DataMember attribute for each property or field you want to serialize and transfer between service and client. Collections are by default created as arrays. If you don't like it you can change this behavior in Add Service Reference window -> Advanced settings where you can select which collection type should be used.
First off, each of the properties that you want to serialize should have the [DataMember] attribute:
[DataContract]
public class Software
{
[DataMember]
public string SoftwareID { get; set; }
[DataMember]
public string SoftwareName { get; set; }
[DataMember]
public string DownloadPath { get; set; }
[DataMember]
public int PackageID { get; set; }
}
Second, the translation to an Array would be handled by the client, not the server.
You can mantain List instead of array on the clien when you add the Service Reference: click the "advanced" button and change the collection type to the one you want.
I was suffering with same problem and now I solved it! It was a ServiceKnownType problem. If you have a in known type loader we have to add runtime Type like;
Type aaa = Type.GetType("System.Collections.Generic.List`1[[ProjectName.BusinessObjects.Bank, ProjectName.BusinessObjects, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null]]");
knownTypes.Add(aaa);
Anyone having same problem can try this. It's working in my environment!