WCF Deserialization Problems - web-services

I am facing de-serialization problems in using Microsoft.Xrm.Sdk dll in WCF service.
while generating the client side proxy class, All the derived types of type (DataCollection) is changed to a different namespace and type as mentioed below.
In DLL
public sealed class AttributeCollection : Microsoft.Xrm.Sdk.DataCollection<string,object>{}
In Proxy Using (SvcUtil)
public class AttributeCollection : System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, object>> {
}
Regards,
Ranjith

Related

Error when deserializing Java client request to WCF service

I have a WCF service with yet only one method:
[OperationContract]
void SaveDocument (InwardDocument doc);
[DataContract]
public class InwardDocument{
[DataMember]
public Citizen Citizen {get;set;}
....
}
[DataContract]
public class Citizen{
[DataMember]
public string LastName {get;set;}
....
}
I've tested the service with both WCF test client and a separate .NET console application. In both cases the service works as expected. But when a java client tries to consume it, a deserialization problem occurs. I've put some markers inside the SaveDocument method to see what causes the problem:
public void SaveDocument(InwardDocument doc){
if(doc==null)
throw new ArgumentnullException("InwardDocument");
if(doc.Citizen==null)
throw new ArgumentnullException("InwardDocument.Citizen");//This exception is thrown when consumed by java client
}
As you can see the first exception is skipped which means doc argument itself is not null but for some reason, the Citizen property is null. The guy who generates the request in java client confirms that the InwardDocument.Citizen property is not null by debugging the code. In fact we've had a problem generating the proxy class in that java client which I describe in this SO thread. So I'm assuming it has something to do with that same problem.Maybe I need to add some more attributes to my classes and their members to care of any such problems that might occur in other platforms? Any suggestions are appreciated.
Have you tried to add Know Type attribute in your InwardDocument class. See link here.
[DataContract]
[KnownType(typeof(Citizen))]
public class InwardDocument{
[DataMember]
public Citizen Citizen {get;set;}
....
}
The problem was caused by incorrect creation of the corresponding JAXBelement instances. The solution to the problem is in this SO thread answer

Passing Objects to a Web Service's method

I have recently started working on (Java)Web Services.
I have certain web methods that accept different arguments - primitives,Maps,HttpServletRequest,FlowJob(Spring) etc.
I got numerous issues while attempting this - from a failed web service deployment saying 'interfaces not supported by JAX-WS' to runtime exceptions 'java.lang.Object cannot be cast to org.w3c.dom.Element' !
I have not put the steps deliberately;all I need to know is that is it possible to pass the above arguments to a Java Web Service method? In short,is something like this possible :
#WebService(serviceName = "WS")
public class WS {
#WebMethod
public Object processJob(MapargsMap){
}
#WebMethod
public String processJob(SomeCustomObject object){
}
}
}
Are there any work-arounds to make JAXB marshal and unmarshal custom objects,Maps etc.?If yes,what are they?
Thanks & regards !

Missing dependency for method public entities in Netbeans restful web services

I am deploying a restful web services using Netbeans EE6 and jersey libraries with the tutorial http://netbeans.org/kb/docs/websvc/rest.html.
When I create a restful web services from entities that hold composite primary keys in the database, the project gives me an error when I try to test the web services:
SEVERE: Missing dependency for method public entities.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK) at parameter at index 0
SEVERE: Method, public entities.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK), annotated with GET of resource, class service.RMScheduleFacadeREST, is not recognized as valid resource method.
Is the error due to composite primary keys or is there a step that I should include?
Many thanks in advance.
I think this issue is related to Netbeans bug:
https://netbeans.org/bugzilla/show_bug.cgi?id=208375
When creating entity class which has composite primary keys,
two entity files are created. (ex CustomerEntity.jave, CustomerEntityPK.java)
Then if you choose to create the servlet from the entity class, the servlet comes with automatically generated code such as below:
#DELETE
#Path("{id}")
public void remove(#PathParam("id") CustomerEntityPK id) { //error
super.remove(super.find(id));
}
#GET
#Path("{id}")
#Produces({"application/xml", "application/json"})
public CustomerEntity find(#PathParam("id") CustomerEntityPK id) { //error
return super.find(id);
}
The issue is that argument being passed to the servlet methods is CustomerEntityPK which has composite primary key.
If you change the argument type to something like String then the error went away in my case.
#DELETE
#Path("{id}")
public void remove(#PathParam("id") String id) { //type set to String now
super.remove(super.find(id));
}
But in my project I did not need such auto generated code so I simply choose to create servlet class by hand and has no problem.
Hope that helps.

C# send generated classes from diagram through webservice problem

I have problem with sending a object from my webservice.
I have created a diagram with a product Entity... then I generated the database... C# generates a few classes in a ...Designer.cs file.
In that file I have the class Product which with the following:
[EdmEntityTypeAttribute(NamespaceName="WinkelModel", Name="Product")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Product : EntityObject
I created a webservice with the following method:
public Product[] GetProducts()
{
using (WinkelModelContainer wmc = new WinkelModelContainer())
{
var products = from p in wmc.Products select p;
return products.ToArray();
}
}
But when I start the WCF Test Client to test my webservice I get the following when I want to test this method:
This operation is not supported in the WCF Test Client because it uses type Product
Does anyone has a solution for this problem?
Thanks in advance!
I solved it... This isn't possible in C#. I have to create a seperate class with the same information and send this class with my webservice.

WebService (CF 3.5) and Class Inheritance?

Merged with .NET Compact Framework 3.5 Serialization Problem with Derived Classes.
I use a simple WebService returning a Test Class as Response. The Test Class has a Base Class containing an int and a string field. The Server sets these two fields of the Base Class.
If i use the WebService on a PC (.Net Console Application) eveything works fine (the int and string field of the Base Class are filled) - but under CF 3.5 the fields of the Base Class are always null.
Does there is a limitation using WebService + Class Inheritance on CF ?