Flex & WCF - Enum error - apache-flex

I have a WCF service operation that accepts a data contract parameter of custom type MyQuery -- function Search(q as MyQuery). The MyQuery object contains 2 properties:
MyQuery.SearchPhrase (string)
MyQuery.SearchType (custom enum SearchTypeEnum)
I also have a Flex client application that consumes this service. But when Flex invokes the Search() operation, I get the following error about the enumeration property:
"Cannot find definition for type
'http://mydomain/2009/04/SearchTypeEnum::SearchTypeEnum"
The error is thrown from Flex while it is building the request to the service.
So my question is..... is there any way to work around this issue in Flex? Or is my only alternative to redesign the service without enums?
This is how the enum data contract is defined at the service tier:
<DataContract(Namespace:="http://mydomain/2009/04/SearchTypeEnum")> _
Public Enum SearchTypeEnum
<EnumMember()> [Boolean] = 0
<EnumMember()> [NaturalLanguage] = 1
End Enum
As far as I know this is the correct definition of an enum data contract. I also tried using the ServiceKnownType and KnownType attributes on the service and on the MyQuery class but to no avail.

I would recommend you try that with a trivial .NET client - maybe even a console application. The idea would be to see if you can get any application to work with the service.

I could not find a way to get this to work. Instead I replaced enums with string constants. Not as elegant, but it works.

Related

API-PLATFORM - model with object serialized to string at endpoint

I faced the problem with generating React components with api-platform-generate-crud.
Model has property that is object email.
I have serializer that make my email object a string.
API endpoint is serving string.
It works for GET & POST.
When I try to generate React components error message is
TypeError: Cannot read property '0' of undefined
Looking deeper into it, looks like that generator still see my email as object not a string.
Any idea how I can force API to 'see' email property as string not object ?
The data model you define is authoritative. Types in the Hydra documentation reflect the ones in PHP classes.
Here, the email property is of type object. If you set the related data as a string somewhere, you don't respect this contract anymore. The Hydra documentation is not in sync with the returned data.
You can change the type of the email property in the Hydra documentation by decorating the api_platform.hydra.normalizer.documentation service.
But I would recommend to keep the PHP classes' structure of your entities as close as possible of the structure exposed through the API.
Your classes should reflect the output of the API. You can use custom data providers to deal with more complex data structure (ex: ORM entities) before hydrating the structure to expose.

Modifying a Biztalk message from custom code

Disclaimer: I am a complete biztalk newbie.
I need to be able to read and potentially edit 4 nodes in a biztalk message; preferably this needs to be done from a c# helper class as I am making a service call and also have unit tests written for this.
I already have this class wired up and it works with the XLANGMessage class, the problem I am running into is at this point in the orchestration the message is a Schema based type and doesn't seem to have any way for me to modify it.
I've done some reading and found a few ideas but have not been able to confirm if any of these can work from custom code.
1 write a map to transform the incoming message to the desired type
or
2 write something like this in your helper component to transform the message
public XmlDocument TransformMessage(XLANGMessage message)
Then pass the result document to a biztalk message in a message assignment shape.
responseMessage = xmlDocument;
You may get better performance if you pass streams instead of messages around.
You can pass messages into and out of C# helper classes easily. The simplest way is just to treat input parameters and return values as of type System.Xml.XmlDocument. The XLANG/s engine will safely cast back and forth from the XLANGMessage type to XmlDocument.
As you are essentially creating a "new" instance of the message (messages are immutable in BizTalk), the call to your helper class needs to be performed in a Message Assignment shape, with the outer Construct shape constructing the copy of your original message.
public static XmlDocument UpdateMyMessage(XmlDocument sourceMessage)
{
/* Do stuff to your Message here */
return sourceMessage;
}
A best-practice to consider is to declare all your C# helper methods as Static. This will avoid any issues with de/serialisation of your helper class during dehydration.
Are BizTalk messages immutable?
Generally speaking they are however, by creating a “corrective” orchestration and using a pass by reference option on the incoming message parameter, an existing message can be modified.

About JAXB Databinding in JAX-WS

I have developed webservices using CXF framework. We are exposing all our Database operation(Service Layer) methods as a web service methods. We are using Hibernate for persistence.
For example consider I have one Java POJO class(for hibernate mapping)
named CountryEntity.java with the following
properties(ID,Name,ModifiedDate).
Inside my service layer i have two methods called
#WebMethod
public CountryEntity createCountryEntity(CountryEntity countryEntity);
#WebMethod
public CountryEntity getCountryEntityById(long id);
Based on JAX-WS documentation i understand that it is using JAXB to do
the databinding. When user calling my webservice for creating the new
Country record i dont want the user to send the Id value and Modified
Date value . So what i done is i annotated the propeties(id,modified
date) inside the CountryEntity.java with #XmlTransistent annotation.
So that operation is working fine.
But when i call getCountryEntityById web service method its returning
CountryEntity object but that object dont have the values for ID and
Modified Date property. I understand because of XMLTransistent
annotation the values not getting Marshalling.
Can i change my method createCountryEntity taking parameters like
(String countryName) , so that i no need to include XMLTransistent
annotation in my entity classes.? or Anyother solution for this?
Please help me . Thanks in advance
Since no answer i go with parameters instead of sending an object as parameter. Thank you.

EF4: The closed type 'xxxx' does not have a corresponding element settable property

I'm using this guide to call stored procedure in my projet which using EF4 EDMX through WCFDataservice.
I have mapped a complex type to return items from the stored procedure. If I call the method by http, the XML'result is perfect, but when I call with this code:
public void Test()
{
Uri methodUri = new Uri(entities.BaseUri + "/GetCase");
List<CaseFiltered> result = entities.Execute<CaseFiltered>(methodUri).ToList();
}
I get this exception The closed type CaseFiltered does not have a corresponding element settable property.
I had try this solution but it doesn't work for me.
Have you a solution?
Thank you!
Ok I find the solution according this article
Actually, you did everything
right...However, our client library
does not support materialization of a
collection of complex types directly
(yet). If you look at the output of
the service op, you would see a list
of tag, rather than an Atom
Feed.
My workaround: I'm using Case entities, not the CaseFiltered complex type

How does ninject work at a high level, how does it intercept object instantiation?

At a high level, how do these dep. injection frameworks work?
I can understand if you always instantiate an object via a custom factory like:
IUser user = DepInjector.Get<User>();
I'm guessing what happens is, wherever you defined the mappings, it will look at the type you want and try and find a match, if found, it will via reflection instantiate the type.
Are there dep. inj. frameworks that would work like:
IUser user = new User();
If so, how would it get the correct user, where is it hooking into the CLR to do this? In case of an asp.net website, is it any different?
If you want to know how Ninject works then the obvious place to start would be reading How Injection Works on their official wiki. It does use reflection but it now also uses dynamic methods:
"By default, the StandardKernel will
create dynamic methods (via
System.Reflection.Emit.DynamicMethod)
that can be used to inject values into
the different injection targets. These
dynamic methods are then triggered via
delegate calls."
As for you second example, I don't believe there are any DI frameworks that would do what you ask. However, constructor injection tends to be most common way of implementing IoC, so that when a class is constructed it knows what type to bind to via some configuration binding. So in your example IUser would be mapped to concrete User in config bindings so that any consuming class that has an IUser parameter as part of its constructor would get the correct User type passed in.
AFAIK there's no way to "hook into" object instantiation with the CLR. The only way to use DI in the second case would be to employ an assembly rewriter (i.e. a postprocessor similar to PostSharp) to replace the call to new with a call to the DI factory method (i.e. GetUser) in the compiled code.

Resources