Yossi Dahan [BizTalk]

Google
 

Sunday, December 17, 2006

Serialisation, inheritance and XmlInclude

I keep forgetting this very elegant approach, so here's a note -

When you attribute a member for serialization you can specify the types this member would serialize to using the XmlIncludeAttribute.

When is this useful? - in many cases you will need to use it when you have inheritance implemented.

Consider these two scenarios -

Scenario 1 - you have two classes (x and y) that inherit from a base class b.
you declare a web method that returns b. if you just run the web method and return x or y, any members of the classes that are not declared in b will not get serialized. this is because the XmlSerializer uses the type definition of b to decide how the serialized output should look like.
Add an XmlInclude attribute to you method specifying the two additional types required and the result will get serialized ok.

Scenario 2 - using the same inheritance model (classes x,y and b) you have a fourth class (z) that has a member of type b, at some point you want to seralize an instance of this class, knowing that b can actually contain an object of type x or y.

Again, without the XmlInclude attribute, if you serialize an instance of the class z only field of class b will get serialized for that member. fields of x and y will not get serialized. adding the XmlInclude instructs the serializer to look at these types as well.

and you can see a nice example here

Error when GAC-ing assembly

This was a bit unexpected (but very easy to figure out)-

I've tried to replace an assembly in the GAC the other day by dragging the dll file into the Windows\Assembly folder when I got the following error:


Failure adding assembly to the cache: Cannot create a file when
that file already exists

Right, I've said, must be the explorer view, so I quickly opened VS Command Line and used GacUtil /i only to receive the same error. adding /f did not help.

Strange - I thought - sure the file exists, I'm trying to replace an existing one, as I (and every BizTalk developer, I'm sure) do so many times without a problem.

After playing around for a second or two the answer was found - we had a command line window in that assembly's GAC folder. closing that window (or moving to another folder) allowed me to succesfully add the assembly to the GAC.

I don't really know, but I suspect GACUtil tries to recreate the folder when you GAC an assembly and having the CMD window in that folder did not allow it to be removed (and re-created)

And what was I doing there in the first place? Thats very simple - thats my way of adding pdb's to the GAC to allow debugging remotely...

Wednesday, December 13, 2006

Message does not show up in transform shape

I've added today a simple orchestration to my project.

The orchestration should take in a multipart message, create another message out of that (by using one of the parts as the source message) and return the resulting message to the calling process.

I've created my map and added a transform shape to my process, but when I moved on to select the message parts to use I could not see my input message listed.

Quick investigation revealed the reaons - the multi-part message had one of its parts as a .net class - Int32. changing this to a schema made the message show up in the transform shape dialog.

This does not make sense, clearly it should be possible to map a schema part of a multi-part message to another message regardless of the types of the other parts.

In fact - if you ask me - it would have been great (and not all that difficult I should think), to see support for using a class, or even a simple type as a map source, but that's another matter.

Until, hopeefully, MS issues a fix, there are two workarounds - the unsupported one (I suspect) is to hack the odx file in a text editor to take the part you need, I have had to do it before (because of another issue we've had with the transform shape's dialog) as well as for this and it works just fine.

The other way is to use an interim message with only the schema part - assign to it before the transform and then use that one in the transform, but that has obvious performance impact.

Labels:

Tuesday, December 12, 2006

Enum as a message part

...Does not seem to be supported.

When I created a multipart message and for one of the parts used the .net type selector to pick up an enum declared in one of our classes I got all sorts of wierd compile time errors about missing ) and ] all refering to the source code behind the orchestration.

The way around it is quite obvious and that is to pass the data as an int and keep casting from one to the other, but of course you loose the benefit of having an enum....

Labels:

Saturday, December 09, 2006

Configuration error in the Logging Application Block

We're using the Enterprise library's logging application block as a basis to a tracing and logging service across our solution.

As you can expect the application block is driven by a configuration section in the config files.

Today I got an error along these lines - "The configuration for TraceListener named Trace Listener A is missing from configuration."

I've briefly checked the configuration file and didn't find a problem in my source or listener.

What I did find strange was that I did not used to so called Trace Listener A in the bit of code I was running but another trace listener.

A closer look at the config file (through the skilled eyes of Ben here) revealed the problem - another source had that listener configured but had a leading space in its name.

I did not expect the application block to check the validity of the links between other sources and their listeners, but assumed it only looked at the one it is asked to use in any given time, evidneyly it does validate the entire section.

Thursday, December 07, 2006

Wish list: support for User HTTP headers in the SOAP adapter

The HTTP adapter uses the UserHttpHeaders context property to allow a process to define additional http headers that are required for an outgoing message.

There is no equivalent property in the SOAP adapter; As far as I could tell it is impossible to add custom http headers using the SOAP adapter .

I suppose that generally you should consider adding such bits of information as a soap header in a web service call, but evidently we're using an external, third party, web service that reuqires it. and where there's one...

In any case I think that since, after all, SOAP is implemented over HTTP (in this particular case, as in most others) it makes sense to expose this functionality, and surely it can't be too difficult?

Labels:

More on web services and generics

We've been bitten by this for the third time now (partly due to the size of the team and the fact that not all team members are directly involved in BizTalk development) -


Every now and then someone will add a web method that takes in or returns a Gerenrics list (List of). while this works great (and is indeed very convinient) in the .net world, BizTalk has not yet catched up with generics.

Trying to add or update a web reference that has such a method will return an error similiar to this -

Could not generate BizTalk files. Parameter of the method does not have a namespace. A namespace is required for generating scehma for this type.


The only solution at the moment, I believe, is to wrap the list in an object so that you have a class that contains a list of, and you use this class as your paremeter and/or return type