I just recently modified a WCF service and added two fields to the returning result set. One of the new fields is an integer the other a string, The WCF Service is hosted in IIS as a website. when I invoke the service from a browser it works fine.
In this solution there is a .asxm service that is calls the WCF service . When I run it I get the following error
System.ArgumentException: Encountered unexpected namespace 'http://schemas.datacontract.org/DataAccessLayer.Entities'The namespace must be empty.Parameter name: ns
I then changed the WCF service to remove one of the new parameters the string variable and recompiled it . it worked when called from the .asmx and .wcf service. I then changed the service to return a string rather than an integer and yet again failed. The old resultset from the service does have string and numeric results and it also works along with the new field when it is an integer but not a string!
My Question is there something that I need to do to link the WSDL result set to what the .asxm is expecting so it can return a json result set?
Can anyone help me understand how I could do this without needing the .asxm service I want to return a return json from my WCF Service.
This is the code in the .asmx file that is calling the WCF Service . The error occurs when it hits statement serializer.WriteObject(ms, d);
public string GetCourseRosterDetailByRosterId(int rosterId)
{
Services cmService = new Services();
VEnterpriseCourseRosterDetail[] d = cmService.GetCourseRosterDetailByRosterId(rosterId);
if (d != null)
{
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(d.GetType());
System.IO.MemoryStream ms = new System.IO.MemoryStream();
serializer.WriteObject(ms, d);
return System.Text.Encoding.Default.GetString(ms.ToArray());
}
else
return string.Empty;
}