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 ?
Related
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
I created a basic web service in C# .Net where I have a parent object with 4 levels of inheritance. (example child0 inherits from parent and child1 inherits from child0 etc.)
The parent only exposes a getMessage funcion and each object has a string variable. The function takes a string and returns a string with some characters appended. This was done as a test to try and figure out why the web service proxy in the ABAP world adds the base nodes.
I want to remove the base so that the structure isn't as complicated but it seems once you inherit from another object this is what you will see in SAP. Can one get rid of the base node?
See the screenshot below:
You need to change the definition of your getMessageResult wsdl/XSD. The message type you have defined there is what causes the inheritance of those sub structures.
I'm using Flash Builder 4.5 and flex 4.5 language.
I'm using a webservice to retrieve data in json calling a .php.
<webservice:Webservice id="webservice" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="testResult" result="onTestResult(event)"/>
...
private function onTestResult(e:ResultEvent):void{
Alert.show(ObjectUtil.toString(testResult.lastResult));
}
In the "Test Operation" window of Flash Builder I made my call and the return is a json Object made by arrays.
If I call the same webservice from the code instead, it returns a (object)#0 so an empty Object. No errors thown, just an empty Object.
Anyone has some tips?
The ns prefix of your Webservice class susggests you're using a custom implementation, rather than the framework WebService class. However, you don't provide any specifics, so I'm gonna take a swing in the dark:
If your custom service is based off the HTTPService class, make sure you're setting the resultFormat='text'. The default is XML, which will be causing you problems.
If you're using the Framework WebService class, well - you can't, as it's designed for SOAP webservices, not JSON. (From the Docs for mx.rpc.soap.WebService:)
The WebService class provides access to SOAP-based web services on
remote servers.
If it's some other implementation, please provide more details.
How would you go about integration testing a spring application that is annotation-configured and component-scanned and does not have an XML configuration at all? I'm hitting a wall with the need to replace production components with testing components without actually resorting to xml configuration or reflection injections to all the #autowired parts.
Example:
interface A {...}
#Component
class AImpl implements A {
...
}
interface B {...}
#Component
class BImpl implements B {
#Autowired A a;
...
}
interface C {...}
class CImpl implements C {
#Autowired B b;
...
}
then in my test I want to use ATestImpl, but I only have access to C (integration testing C).
How would you go about doing that?
Take advantage of #Primary annotation:
#Service
#Primary
public class TestA implements A {
//...
}
If there is more than one bean implementing A, Spring will prefer the one annotated with #Primary. If you place TestA class in /src/test/java, it will only be picked up during test execution, on normal context startup Spring won't see TestA and use only avaialble AImpl.
Use a dedicated spring context XML file where you override AImpl with an instance of ATestImpl. Of course, it uses XML, but I don't see any other solution (other than repackaging the application with your ATestImpl annotated class instead of the AImpl one)
The new Bean Profile features in Spring 3.1 address the need to swap injected components for testing by defining profiles e.g. test, production etc.
The link to the blog post is here. The Spring team have today released the second milestone release of Spring 3.1.
You can use a special component scan for your test, that exclude the "normal" class and add the test class.
If you have several different test classes, then they should not have a #Component Annotation (or #Service, ...). Instead they should be loaded by an XML Bean declaration. So you can have different XML files for different setups.
<context:component-scan base-package="com.queomedia.sgcrm.base">
<context:exclude-filter expression="com\.example\.AImpl" type="regex"/>
</context:component-scan>
<bean class="com.example.ATestImpl"/>
Using Spring annotation config classes, code the #Bean methods to interfaces. The prod config can perform a componentscan on the high-level package(s) to load the prod objects and the test configs can individually specify beans to return the test versions of your objects. This works very well for component testing where faking service calls and DAO objects is necessary.
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.