Monday, June 29, 2009

BizTalk WCF-BasicHttp adapter issue with http://www.w3.org/2001/XMLSchema namespace
 
I am using the WCF-BasicHttp adapter to consume outer Web-service and getting the error (actually if I have retry>0, I am getting Warning first. See below:
 
Event Type: Warning
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5743
Date:  ...
Time:  ...
User:  ...
Computer: ...
Description:
The adapter failed to transmit message going to send port "..." with URL "...". It will be retransmitted after the retry interval specified for this Send Port. Details:"Unable to read the stream produced by the pipeline.
 Details: The value 'd:date' is invalid according to its schema type 'http://www.w3.org/2001/XMLSchema:QName' - 'd' is an undeclared namespace. ".
...
 
or (After retry the previous message the retry limit for this port)
 
Event Type: Error
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5754
Date:  ...
Time:  ...
User:  ...
Computer: ...
Description:
A message sent to adapter "FILE" on send port "..." with URI "..." is suspended.
 Error details: Unable to read the stream produced by the pipeline.
 Details: The value 'd:date' is invalid according to its schema type 'http://www.w3.org/2001/XMLSchema:QName' - 'd' is an undeclared namespace. 
 MessageId:  ...
 InstanceID: ...
...
 
Very srange. When I tried the same Web-service with SoapUi, the result of the verification of the Response message is similar.
 
line 8: Invalid xsi:type qname: 'd:string' in element ...@http://...
 
What is wrong with response message?
 
Response Message:

<e:Envelope xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn1="..." xmlns:wn2="..." xmlns:wn0="..." xmlns:e="http://schemas.xmlsoap.org/soap/envelope/">
   <e:Body>
      <wn2:ActionResponse>
         <wn2:MyResponse i:type="wn2:MyResponseType">
            <wn2:Detail i:nil="true"/>
            <wn2:MyMsg i:type="wn2:ArrayOfMyMsgType">
               <wn2:MyMsgType i:type="wn2:MyMsgType">
                  <wn2:MsgDescriptionText i:type="d:string">...</wn2:MsgDescriptionText>
                  <wn2:MsgIdentificationID i:type="d:string">...</wn2:MsgIdentificationID>
                  <wn2:MsgSeverityLevelCode i:type="wn2:MsgSeverityLevelType">...</wn2:MsgSeverityLevelCode>
                  <wn2:MsgSourceText i:nil="true"/>
               </wn2:MyMsgType>
            </wn2:MyMsg>
         </wn2:MyResponse>
      </wn2:ActionResponse>
   </e:Body>
</e:Envelope>
 
Investigation discovered that the issue is in the namespace prefix "d". If I change it to the "xsd", the error disappeared.
 
Questions:
How to work around this?
Is it the error in the response message?
Is it an error in the WCF-BasicHttp adapter?
 
How to work around this issue?
I changed the WCF-BasicHttp port for the old SOAP port and SOAP port works fine.
 
Is it the error in the response message?
I didn't find any limits for the "http://www.w3.org/2001/XMLSchema" namespace and for prefixes for it. The only limit is "don't use the prefixes, started with 'xml' letters". It is the common practice to use "xsd" prefix for the "http://www.w3.org/2001/XMLSchema" namespace. But it is not the rule.
Seems the WCF-BasicHttp adapter is "too smart".
 
Is it an error in the WCF-BasicHttp adapter?
possible...

Wednesday, April 08, 2009

.

BizTalk 2009: notorious Microsoft ADO MD.NET 9.0 and 10.0

 

When I was installing the BizTalk 2009 the Setup asked these prerequisite components:

Microsoft ADO MD.NET 9.0 and

Microsoft ADO MD.NET 10.0

 

I did not have Internet access and I had to manually search for these components.

Seems it is not a simple googling. :)

 

After painful search I've found them here:

1) ADO MD.NET 9.0:

Page "Feature Pack for Microsoft SQL Server 2005 - November 2005" - http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en

[- follow PageDown to]

Microsoft ADOMD.NET

...

X86 Package (SQLServer2005_ADOMD.msi) - 3302 KB

X64 Package (SQLServer2005_ADOMD_x64.msi) - 5430 KB

IA64 Package (SQLServer2005_ADOMD_ia64.msi) - 6906 KB

 

2) ADO MD.NET 10:

Page "Microsoft SQL Server 2008 Feature Pack, October 2008" - http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=228de03f-3b5a-428a-923f-58a033d316e1

[- follow PageDown to]

Microsoft ADOMD.NET

...

X86 Package(SQLSERVER2008_ASADOMD10.msi) - 4312 KB

X64 Package (SQLSERVER2008_ASADOMD10.msi) - 9263 KB

IA64 Package(SQLSERVER2008_ASADOMD10.msi) - 6776 KB

 

 

As you can see there is a bad inconsistency in the names!

Hope this article saves you several minutes.

Wednesday, April 01, 2009

.
BizTalk: What features we would like to see in future releases
After the MVP Summit [http://geekswithblogs.net/LeonidGaneline/archive/2009/03/09/microsoft-global-summit-mvp-most-valuable-professional-2009-pictures.aspx] we, the BizTalk MVPs, have been asked to give feedback to the product team on what features we’d like to see in future releases.
I created the list of features and separated it into parts. One is from the global, crazy things than never be implemented. But why don’t imagine? Second one is from the small things.
Let start from the big, crazy things:
More flexibility in the deployment and licensing.
What I mean:
1)   Why don't move the BizTalk as a product to cheap segment? (cheap? No, let's talk about bigger)
a)   BizTalk + SQL Express on one box. Then creating a farm of the BizTalk applications would be easier. Load Balancing is moved outside, before the farm. Maybe create a separate product the "BizTalk load balancer"?
b)   Moreover, ship the preconfigured VHD with BizTalk + SQL Express + Windows Server. With possibility to create the farm from these VHDs. (Not so easy because now we have strict limit to the SQL and BizTalk server names, and that limit should be fixed anyway.)
2)   Why don't move to the expensive segment?
a)   Shift to the Windows HPC? What about this? One time the BizTalk was pioneered as the first enterprise level product by Microsoft, created on .NET. Using the HPC methods to get rid of SQL completely, perform all persistency in memory to get super-low latency product.
3)   Reiterate the architecture with all spectrum new Microsoft technologies. Is it possible to extract the MessageEngine, the OrchestrationEngine, and the UnifiedInputOutput Engine to separate products?
4)   At last extract the BRE to separate product or free library! Now it is dead. Give BRE a shock treatment.
5)   Redesign the error processing for different stages of the message processing. Now there are different approaches are used in many places or nothing at all.
6)    Extract the LOB Adapters to separate product on the “buy if you need it” basis or to the free library. Create the Internet store and sell adapters for small money to everyone not only to the buyers of the BizTalk. Sell them not in packages but per adapter.
Now the small things:
Many years there were no improvements in very basic things, the things the developers are using in everyday tasks. I mean: adapters: File, SQL; pipelines; schema and map editors; additional shapes in Orchestrations, etc.
1.      Adapters:
a.    File adapter (for example): add the possibility to use the file names to order delivery (process files in the sorted order, many variations J ); implement the file receive filters with regEx on the file names; add possibility to copy files to other folder after consuming (to make some sort audit/resubmit storage, in forums this question is repeated and repeated, "How we could make a copy of the original files?")
b.    SQL adapter: OMG, there should be many changes in real-time functions and much more improvements in the design-time appearance. I'd prefer to use not the standard Wizard to generate SQL port artifacts but some sort rich-UI window to set up different stages of artifact creation and the real-time parameters.
I am sure the brainstorm by BizTalk MVP should generate a lot of good ideas.
c.      Additional adapters: like Task Scheduler; Nope; Fan-out/Garbage (to consume messages without subscribers in the pub/sub application); PowerShell (for additional processing of the input/output messages). Brainstorm this! Buy these adapters from the third-parts, unify them and include to the standard package.
d.      Please, make InfoPath integration with BizTalk easy as hell!!!! (Isn't it a prime purpose of InfoPath??? To integrate the BizTalk with human?)
2.      Pipelines (pipeline components): where are? the xml <-> PDF ; zip/unzip ; map (yeah! what is wrong with it?); different coders/decoders; symbol (regex) replacement (for EDI processing it MUST be!); PowerShell (for additional processing of the input/output messages); "create message" pipeline; Excel/Word ; Html ; simple EDI (to very basic EDI processing); promote properties from the text; etc. . Brainstorm this!
3.      Add the error processing to the standard interfaces of the custom pipeline components.
4.      Transmitting raw/binary data. Frequently we only use the BizTalk to transfer and route the documents (messages) without transformation. Now it is the second-class citizen scenario.
5.      Orchestrations: additional shapes as: CreateMessage !!!; throwEvent; Pipeline transformation (?).
Make shapes resizable, otherwise we should use odd methods to make the Orchestration more descriptive. How we could show Orchestration to business people if we cannot add enough text to shapes???? Add color to shapes.
Make the Expression Editor window resizable, dockable, fully InteliSensed, etc. !!!!!!!!!!!!!!!!!!
6.      Schema editor: Use the schema node icons for more useful information, definitely, for cardinality (say, different colors for "max occurs = *", for "min occurs = 0"). Maybe add separate window for the referenced (included) schemas?
7.      Map editor: add functoids [IfElse]... Make improvements to the Script functoid!!! Separate to InlineScript; ExternalScript (ExternalMethod?); XsltScript...; make InteliSense to the Inline Script and Xslt script windows. Use the source/target node icons to more usefull information. See http://geekswithblogs.net/LeonidGaneline/archive/2005/12/23/64004.aspx - it is an old list but still actual.
8.      Ports: Please, make ports the first-class artifact as an Orch. Why we should use the orchestration assembly just to store the port type??? Why do we use the "logical port" term in Orchestration editor? It is not a port, it is just an endpoint. Orchestration has the endpoints and the Port has the endpoints. My perception it should be big redesign of the "port part" of the BizTalk architecture. Right now it is a mix of adapters, pipelines, maps, etc. without strict regulation, strict design. This mix is very static, could not be used in structured way to improve the development.

The question to us was: 1) What was/is THE GOOD stuff about the area? 2) What is just plain BAD? 3) What is UGLY about the feature area e.g. if you were developing this feature what would you do to improve it.
I am sorry but I used the same words. To me “UGLY” and “BAD” are just synonyms for ”rudimentary implemented” and “implemented in beta version”.
1)   Monitoring, operations. Now it is UGLY. No real real-time :). See how it works on HPC Windows, for example.
2)   Debugging is plain BAD.
3)   BRE is good, but EVERYTHING for development BR, everything is UGLY.  Development, testing-debugging (come on, have somebody seen the test text window in Composer? the text inside it????), deploying. BRE now is good, very good to sell the BizTalk to business people, and BRE is just pain in ass for developers. Examples?
http://geekswithblogs.net/LeonidGaneline/archive/2006/12/27/102156.aspx
http://geekswithblogs.net/LeonidGaneline/archive/2006/10/16/94245.aspx
Now as a rule of thumb, I use the BRE for POC projects and never for real projects.
4)   To me BAM is kind of partly implemented. Run-time is very good. Design-time is BAD.
5)   ESB. IMHO if the BizTalk gets the Web-service (or metadata) repository, it has ALL ESB functionality and could be named ESB to business people. MVPs discussed this many times on the Summit.
6)   Of course, low latency must be implemented.
 

Monday, March 09, 2009

 
Hi All,
I've made pictures on the
Microsoft Global Summit MVP [Most Valuable Professional] 2009 March 1-4, Seattle, Redmond.
Mostly the BizTalk MVPs.
Steve Ballmer, many vice presidents, Microsoft Fellows, developers from different product teams.
It was fun.
Stephen W. Thomas, Alan Smith, Robert Hogg, Saravana Kumar, Joao Pedro Martins, Ben Cline
Steve Ballmer - Thinker
Microsoft Fellows

Wednesday, October 15, 2008

 

Review "MCTS Self-Paced Training Kit (Exam 70-503): Microsoft .NET Framework 3.5 Windows Communication Foundation (PRO-Certification)"

http://www.amazon.com/MCTS-Self-Paced-Training-70-503-PRO-Certification/dp/0735625654/ref=sr_1_12?ie=UTF8&s=books&qid=1224042536&sr=8-12

I like this series of books (SPTK - Self-Paced Training Kit) because the short theory here is always ended with real world examples. And these examples shows how the product is used in the real situations, to solve the real problems. It is like the prioritization of the functionality.

In the WCF documentation on the MSDN there is no such prioritization, great list of the features is here and no clue what are the main features and what are the secondary, additional features.

In the SPTK books there are no place to all features, the goals of these books are different. There are only the main features and steps how they are used to get the real result. For example, the part about MessageContract. A lot of information are in the MSDN, but it is realy hard to understand what the purpose of the MessageContract is. The real world example is shown in this book, how to use the MessageContract to transmit the license key to the client. Short example gives us the understanding of this artifact.

I am working with Web-services more then 4 years, and last year mostly with WCF-services. I was using this book to review my knowledge to make it more systematic. I didn't use this book to prepare for exam ( See discussion about the sertification exams here http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3280207&SiteID=1 )

I use every information source to *understand* what is going on inside the product, why these features were included in the product, what alternatives were and are. Why so? Knowledge does not stucked in my brain without answers to this questions. I could not study the product in the *button-by-button* style as monkey.

I have to know *why*.

Teaching technics usualy use the patterns how the product should not be used, the samples of the improper practice. Usualy it is hard to teach proper technics without list the improper practices. Sometimes one sample of the wrongdoing is worth dozens samples of welldoing.

How does this series of books the SPTK is different from oother books published by Microsoft?

  • Here are only described the *main* product features. These features were selected by Microsoft itself and it works as a unofficial priotirizing. It is very important.
  • Here we see the *real world* problems and ways to resolve them with help of the main product features.
  • In these books are the concisely description (and sometimes the history) what was the *source of these features*.
  • Here we could see the samples of the *improper practice*, how the product should not be used.

 

Pros:

  • This book is the Microsoft vision of what is the intend of the WCF, how the WCF should be used.
  • The concise information about WCF is concentrated in the *Lessons*. The real world samples are placed near it. These samples are also concentrated on the main things.
  • I very like the *Lesson Summary* parts. These lists are the lists of the *prime features* of the WCF.

Cons:

  • Sometimes the book gives us the method in the samples that are obsolete. Say, the generation of the classes from XSD with XSD.exe utility. Several generation of the Software Factory could make this and SvcUtil.exe so.
  • Sometimes the description are not perfect. I have feeling that authors did not squeeze out the whole information from the BizTalk team :) and this is not surprize me because of the huge WCF feature pool. (For instance, we are asked on page.66 to comment attribute the [XmlSerializerFormat...] and regenerate scheams again, then make sure these schemas are going to get big differences from the default schemas. All these exisises with regenerating are useless without detailed explanations.)

 


Conclusion:

I know several good sources of the information about WCF for deep studing.

- and this book is good addition to this list.

I mark this book with 5 stars.

It has flaws, but benefits of using it as a fast and reliable source to study WCF are great.

Best regards!

 



Tuesday, October 14, 2008

The WCF has such structure of the performance counter names:
http://msdn.microsoft.com/en-us/library/ms735098.aspx

   ServiceName@ServiceBaseAddress
  (ServiceName).(ContractName)@(endpoint listener address)
  (ServiceName).(ContractName).(OperationName)@(first endpoint listener address)

In MSDN we have:
"There is a limit on the length of a performance counter instance's name. When a Windows Communication Foundation (WCF) counter instance name exceeds the maximum length, WCF replaces a portion of the instance name with a hash value."  http://msdn.microsoft.com/en-us/library/ms731052.aspx


In my case WCF has generated the names:

  notif28.inoti60.removebyrefer54@82rapper|notificationwrapper.svc
  notif28.inoti60.removebymsgid@82rapper|notificationwrapper.svc
  notif28.inoti60.removebyemailid@82rapper|notificationwrapper.svc
  notif28.inoti60.schedule@82rapper|notificationwrapper.svc

(Sorry for rapper :) Originally it was Wrapper)

The question is:
Can I use these names as hard-coded names or
next time the WCF could generate different names???
BTW Such names with a hash value are disaster if I need to use the performance counters in my code.

Say I'd like to get counters for the operation with name "RemoveByReferenceMessage" name.
How I can find my counters with code if I have names:
notif28.inoti60.removebyrefer54@82rapper|notificationwrapper.svc
notif28.inoti60.removebymsgid@82rapper|notificationwrapper.svc
notif28.inoti60.removebyemailid@82rapper|notificationwrapper.svc
notif28.inoti60.schedule@82rapper|notificationwrapper.svc


???
How many chars of the operation name I have to use for search?
How many chars of the endpoint name I have to use for search?
How many chars of the service name I have to use for search?
One good part of this is that is the hash algorithm always gives us the same names. Al last in my experience.
Now I know only one method to use WCF performance counter names in the custom code:
  1. Start WCF service and get the generated performance counter names from the PerfMon.
  2. Use these names in the code.
Disadvantages: After any change in the ServiceName, ContractName, OperationName, ServiceBaseAddress, EndpointListenerAddress we have to repeat these steps again.


Thursday, October 09, 2008

Sometimes in the BizTalk forums such questions appear.
"...I have been using event log to test variables. I was hoping there was a way to watch it process in VS like you can debug a forms app."

There is a difference in the usual app and in the "BizTalk app".
When you start usual app it is exactly this app and you could debug it. When you "start" the BizTalk app that could means *many* *instances* of this BizTalk app could works simultaneously.
With BizTalk you have an intermediate layer, the host. This host (actually it is a host instance but it doesn't matter for this case) manages the app *instances*. It could start many app instances simultaneously and then dehydrate, rehydrate, stop, abort them without our intervention.
Ideally we need to attach a debugger to exactly one app instance (which one?) or create a debugger working with many app instances simultaneously.
It is one of the source of the complexity of debugging the BizTalk apps.
BTW What is a BizTalk application at all?

Please, let me know, what do you think.

Wednesday, October 08, 2008

Hello,
 
Before Dublin is in charge, especially the Repository for the Web-services I'm using the custom code to manage the buzz  with many URLs in Web.config files
 
There is a utility to change all URLs in .config files by one click.

 
1. Purpose.
In my current project we've got a lot of composite WCF-services. We have several environments: Development,Test1, Test2, Production.
We don't have the service repository. That means when we move the services from one environment to another, we have to change addresses (URLs) in the <client> sections of all Web.config files (several dozens). Boring and error prone work, isn't it?
 
The FilesModificatorAdmin utility was created to change all addresses in all Web.config files by one click.
 

2. How it works.
We define the files that should be scanned and changed. We define the root folder for search. We define the replacements substrings like "http://Env1.MyCompany.com/Composite/Promo/PromoService.svc". The utility derives the searching substring RegExes from the replacement substrings like ""http[^\"]*?PromoService.svc".
 
Then the FilesModificatorAdmin utility scans all defined files in all folder tree and replace the substrings.
Utility creates the copy of the changed files as OldName.copy.
Utility output the progress to the screen and optionally to the log file.
Utility could optionally just scan the files and show how many searching substrings were found and where.
 

3. Notes.
 * The rules to derive the RegEx for the search are hard coded.
 * If the FilesModificatorAdmin found the searching substrings but the string does not changed (it is possible because the searching sub string RegEx could find the substring that is equal the replacement substring) the FilesModificatorAdmin does not change the substring. In this case it shows that sub strings were found if option the "find only and do not replace the Substrings" is checked, and it shows that substrings were not found if option the "find only and do not replace the Substrings" is unchecked.
 


GLD (C) 2008

Tuesday, September 02, 2008

There is an interesting discussion "BizTalk, From Hub/Spoke to ESB" in the MSDN BizTalk forum: [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3478379&SiteID=1]

Thursday, July 10, 2008

 This is a Part 4 of the Interview articles.
Part 1: "BizTalk 2004, Questions for interview without answers" http://geekswithblogs.net/LeonidGaneline/archive/2006/05/22/79267.aspx  
Part 2: "BizTalk interview questions and principle" http://geekswithblogs.net/LeonidGaneline/archive/2007/07/03/113663.aspx
Part 3: "WCF: Questions for studing and interview" http://geekswithblogs.net/LeonidGaneline/archive/2008/01/07/wcf-questions-for-studing-and-interview.aspx  

Please, mark your skills in the table. 
I completely understand that nobody ever tried ALL the BizTalk features.    
   
Name                                                      Number of the Projects      Months             Skills Mark (1..10 or A,B...)

artifacts:
 applications   
ports, groups, locations   
FTP   
SOAP   
HTTP   
SQL   
WCF   
SMTP, POP3   
MSMQ   
SharePoint   
LOB: EDI base, Siebel, etc. (name them)   
pipelines
pipeline components   
schemas   
maps   
database functoids (or custom DB mapping)   
Xslt   
Xslt templates   
orchestrations   
transactions   
atomic scope  
long-running   
compensation scope    
exception scope     
persistent points   
correlations   
helper .NET classes   
SQL data bases (with relation to the BizTalk)   
hosts, instances   
adapters   
parties   
EDI, AS2 system   
policy, rules, vacabularies   
BAM   
BAS 
Development: 
orchestrations   
port-to-port   
helper .NET classes   
custom adapters   
custom pipeline components   
custom functoids   
rules…   
BAM   
BAS   
ESB  
 Debugging Tuning-Up:   
VS
Nunit   
BizUnit   
LoadGen   
stress testing   
performance metrics   
different utilities (name them)   
multi-server debugging   
MOM   
HAT   
Adm.Console   
PerfMon   
Deployment: 
BTSDeploy   
BTSTask   
MSI, Binding   
multi-server deployment   
clustered MessageBox   
WMI scripts  
   
Development techniques:   
   - correlation   
   - convoy parallel   
   - convoy sequential unified   
   - convoy sequential non unified   
   - long-running transaction   
   - transaction compensation   
  - FIFO   
   - send data to SQL   
   - receive data from SQL   
   - data validating   
 - error handling in the BizTalk applications   
  - BizTalk to/from WS/HTTP apps   
* test-driven development   
* .NET development tools   
   
Programming skills:   
* test-driven programming   
* VS.NET   
* script languages, utils   
* SQL: database normalization, programming   
 Web-programming   
low-end programming   
   
   

   
Several questions (sorry, no more than 2-3 min for answer):
 
  • How do you study BizTalk? what are the main sources of the information? 
  •  Describe creating the full-featured BizTalk application. Just the steps.   
  • Describe debugging the full-featured BizTalk application.   
  • Describe deploying the full-featured BizTalk application.   
  • Monitoring the BizTalk application:   
       


   
Skills Mark Legend:   
 can describe purpose and functionality 
 2 made Sample(s) 
 3 used in one project 
 used in one project recently  
 used in several projects 
 6 used advanced functionality 
 can show my answers in forums and articles in blog 
 8 used API (in code) 
 9 can teach other developers, can show pro and cons 
                 OR  
 A know something 
 B can use in standard cases 
 C can use advanced features, API 
 expert 

Wednesday, July 09, 2008

Interesting information in KB:
"How to use distinguished fields and promoted properties in a BizTalk Server project" http://support.microsoft.com/kb/942250
 
"...
  • A promoted property may not be available as a promoted property after you write a value into the message context. This situation can occur if the value that you write into the message context has the same name and namespace that was used to promote the property.
  • Properties that have a null value are not permitted in the message context. Therefore, if a null value is written into the message context, this value will be deleted.
    ..."
 
BTW What is it "a null value"?
  • Is it <shipDate xsi:nil="true"></shipDate> ?
  • Is it absence of the value <shipDate></shipDate> ?
  • Is it "closed tag <shipDate /> ?
  • Is it absence of the whole node?
 
In http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/#Nils we have description of it. But frequently we've got different interpretation of this term. And I am not sure about interpretation in KB
 
 
And let me add one more, not obvious:
  • Distinguished fields and promoted properties have to always get Min/Max Occurs = 1. (Not 0, not "unbounded", only 1)

Tuesday, June 24, 2008

Notes

·         Bindings are spread across several namespaces.

·        DataContractAttribute is placed in the System.Runtime.Serialization namespace not in the System.ServiceModel namespace.

·         Configuration sections are spread across several namespaces.

·         ClientSection and ServicesSection: First has the structure client/endpoint, the second – services/service/endpoint. Asymmetric.


System.ServiceModel.dll

System.ServiceModel

·         ServiceHost

·         ChannelFactory<TChannel>

·         ClientBase<TChannel>

Contracts:

·         ServiceContractAttribute

·         OperationContractAttribute

·         MessageContractAttribute

·         FaultContractAttribute

Bindings:

·         BasicHttpBinding

·         NetMsmqBinding

·         NetNamedPipeBinding

·         NetPeerTcpBinding

·         NetTcpBinding

·         WS2007FederationHttpBinding

·         WS2007HttpBinding

·         WSDualHttpBinding

·         WSFederationHttpBinding

·         WSHttpBinding

Exceptions:

·         CommunicationException

·        

 

System.ServiceModel.Activation

·         ServiceHostFactory

·         WorkflowServiceHostFactory

System.ServiceModel.Activation.Configuration

·         DiagnosticSection

System.ServiceModel.Channels

Interfaces:

·         IChannel

·         IChannelFactory<TChannel>

·         IChannelListener<TChannel>

Abstract classes:

·         Binding

·         BindingContext

·         BindingElement

·         ChannelFactoryBase<TChannel>

·         ChannelListenerBase<TChannel>

·         CommunicationObject

·         Message

·         MessageHeader

·        

Bindings:

·         CustomBinding

Binding Elements:

·         TransportBindingElement

·         MessageEncodingBindingElement

·        

System.ServiceModel.Configuration

Sections:

·         BehaviorsSection

·         BindingsSection

·         ClientSection

·         DiagnosticSection

·         ServicesSection

Element: System.Configuration.ConfigurationElement

·         BaseAddressElement

·        

ElementCollection: System.ServiceModel.Configuration.ServiceModelEnhancedConfigurationElementCollection<ComMethodElement>

·         BaseAddressElementCollection

·        

System.ServiceModel.Description

·         ServiceEndpoint

Behavior interfaces:

·         IContractBehavior

·         IEndpointBehavior

·         IOperationBehavior

·         IServiceBehavior

Descriptions:

·         ContractDescription

·         FaultDescription

·         ServiceDescription

System.ServiceModel.Dispatcher

·         ChannelDispatcher

*     ClientOperation

*     ClientRuntime

·         EndpointDispatcher

Filters:

·         ActionMessageFilter

·         MatchAllMessageFilter

·         MessageFilter

·        

System.ServiceModel.MsmqIntegration

·         MsmqIntegrationBinding

System.ServiceModel.Security

Credentials:

Encoders:

System.ServiceModel.Security.Tokens

Tokens:

SecurityTokenParameters:


System.Runtime.Serialization.dll

System.Runtime.Serialization

Attributes:

·         CollectionDataContractAttribute

·         DataContractAttribute

·         DataMemberAttribute

·         EnumMemberAttribute

 

 

System.WorkflowServices.dll (v3.5)

System.ServiceModel

·         WorkflowServiceHost

Bindings:

·         BasicHttpContextBinding

·         NetTcpContextBinding

·         WSHttpContextBinding

 

 



Thursday, June 19, 2008

We should install the certificate to the server that hosts the services with Transport level security.

For tests we could use the self-made certificate, for production we recommend to use the certificate issued by the industrial certificate provider as the VeriSign.

1.       Install Microsoft .NET Framework 2.0 Software Development Kit (SDK) (x64) [http://www.microsoft.com/downloads/details.aspx?familyid=1AEF6FCE-6E06-4B66-AFE4-9AAD3C835D3D&displaylang=en]. It is installed by default to the "C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin " folder.

2.       [Optionally, only if you also have server certificate and want to refresh it]"C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin\certmgr.exe" -del -r LocalMachine -s My -c -n MyCompany-HTTPS-Server

3.       "C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin\makecert.exe" -sr LocalMachine -ss My -n CN= MyCompany-HTTPS-Server -sky exchange -sk MyCompany-HTTPS-Key

4.       Install the new certificate to the IIS by the Web Server Certificate Wizard. Open IIS Admin, choose the Web-site, Properties, Directory Security tab, Secure communicationServer Certificate… button, it starts the Web Server Certificate Wizard .

5. Check if the IIS / Web Site / Properties / tab Web Site - SSL Port set up to 443 (

 


To expose the service metadata by HTTPS and HTTP use:

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior_Name">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

To expose the service metadata by HTTPS or HTTP only, change attribute the httpsGetEnabled or httpGetEnabled to false.


Monday, June 02, 2008

After creating simple WCF service I've got strange errors (see below).
 
Th issue was in the names of the response messages.
I used the simple custom rule to name request and response messages (.NET DataContract classes):
<OperationName>Request and <OperationName>Response
For instance I created GetTokenResponse class for the response message of the GetToken operation.
 
And this is the wrong rule!
Why? Because the WCF creates these names for the WSDL metadata files:
 
For instance I've got:
...
<wsdl:message name="ITokenStore_GetToken_OutputMessage">
  <wsdl:part name="parameters" element="tns:GetTokenResponse" /> ...
 
....<wsdl:operation name="GetToken">
  <wsdl:input wsaw:Action=http://MyServices/TokenStore/2008-05-29/ITokenStore/GetToken message="tns:ITokenStore_GetToken_InputMessage" />
  <wsdl:output wsaw:Action=http://MyServices/TokenStore/2008-05-29/ITokenStore/GetTokenResponse message="tns:ITokenStore_GetToken_OutputMessage" />
 
 
When I changed the name to the GetToken_Response the errors disappeared.
It is not an error in the WCF it is just undocumented feature.
The problem is the error text gives us unhelpful and ambiguous information.
 
See the article in MSDN: http://msdn.microsoft.com/en-us/library/ms731045.aspx
Not a clue about these rules.
Conclusion:
Don't use the name convention for the request and response messages (.NET classes) like <OperationName>Request and <OperationName>Response !
 

Error in SoapUI
, when we've tried to get the metadata:
... ERROR:javax.wsdl.WSDLException: WSDLException (at /HTML): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
 

Error in IE: by address the <ServiceAddressURL>

The service encountered an error.

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
 contract: http://MyServices/TokenStore/2008-05-29:ITokenStore ----> System.Xml.Schema.XmlSchemaException: The global element 'http://MyServices/TokenStore/2008-05-29:GetTokenResponse' has already been declared.
   at System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
   at System.Xml.Schema.BaseProcessor.AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item)
   at System.Xml.Schema.Preprocessor.Preprocess(XmlSchema schema, String targetNamespace, ArrayList imports)
   at System.Xml.Schema.Preprocessor.Execute(XmlSchema schema, String targetNamespace, Boolean loadExternals)
   at System.Xml.Schema.XmlSchemaSet.PreprocessSchema(XmlSchema& schema, String targetNamespace)
   at System.Xml.Schema.XmlSchemaSet.Reprocess(XmlSchema schema)
   at System.ServiceModel.Description.MessageContractExporter.Compile()
   at System.ServiceModel.Description.DataContractSerializerMessageContractExporter.Compile()
   at System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32 messageIndex, Object state)
   at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
   at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
   --- End of inner ExceptionDetail stack trace ---
   at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
   at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
   at SyncInvokeGet(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Error in IE: by address the <ServiceAddressURL>?wsdl

The service encountered an error.

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
 contract: http://MyServices/TokenStore/2008-05-29:ITokenStore ----> System.Xml.Schema.XmlSchemaException: The global element 'http://MyServices/TokenStore/2008-05-29:GetTokenResponse' has already been declared.
   at System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
   at System.Xml.Schema.BaseProcessor.AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item)
   at System.Xml.Schema.Preprocessor.Preprocess(XmlSchema schema, String targetNamespace, ArrayList imports)
   at System.Xml.Schema.Preprocessor.Execute(XmlSchema schema, String targetNamespace, Boolean loadExternals)
   at System.Xml.Schema.XmlSchemaSet.PreprocessSchema(XmlSchema& schema, String targetNamespace)
   at System.Xml.Schema.XmlSchemaSet.Reprocess(XmlSchema schema)
   at System.ServiceModel.Description.MessageContractExporter.Compile()
   at System.ServiceModel.Description.DataContractSerializerMessageContractExporter.Compile()
   at System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32 messageIndex, Object state)
   at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
   at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
   --- End of inner ExceptionDetail stack trace ---
   at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
   at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleMetadataRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
   at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
   at SyncInvokeGet(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)


Tuesday, May 13, 2008

WCF: Technique of debugging inconsistency between Wsdl and Response messages.

 

I was working with several web-services as a client and had several issues the same kind. WSDL of this services does not conform the Response messages (See below. I’ve bolded the text related to the issue.). I fixed this issue by changing proxy code. It is not a big issue but now we have to manually change proxy every time we have updated the proxy of this service.

 

Here the checklist how debugging this case:

[The proxy for the web-service could be created with any method in Visual Studio 2008 as “Add Service Reference”.]

1.       We have found that the client code cannot get all data from the service. Some data are lost.

2.       Using SoapUI make sure the Response returns all data. This is the sign of this inconsistency!

3.       Using debugger we have found that the data are lost exactly in
      response = client.Method(request)
line in the client code.

What does it mean? The data are successfully returned in the Response message. But the client proxy code could not process them. When the proxy code is deserializing the response message some data are lost. SoapUI does not process returned data, it just shows them as raw text. The proxy code is trying to deserialize this text, converting text to objects in memory. [The deserializer is the code in the Microsoft libraries in the System.Runtime.Serialization namespace. There are two of them in WCF: XmlSerializer and DataContractSerializer.] Some of returned data magically disappeared in the Deserializing process. Description of these cases is in article “WCF: values disappeared in response: derived classes and serialization/deserialization order error” [http://geekswithblogs.net/LeonidGaneline/archive/2008/05/01/wcf-values-disappeared-in-response-derived-classes-and-serializationdeseriazlization-order.aspx]

4.       Go to the proxy source code (maybe in Refeference.cs file) and fix code (see below). This make proxy inconsistent with Wsdl file and next time when you update this Web or Service reference you have to fix proxy code again. But the client deserializes the Response messages properly now!

5.       Document this fix! And do not make it in proxy code. J

You lucky if you have got inconsistency in Response messages. The worst situation if inconsistency is in Request messages. There are only two options: the service does not care about these inconsistencies and you are lucky again, or service reject your request with fault message. Moreover I make sure this message does not give you a clue what is going on.  Try to get the “correct” request from any source and follow the same debugging technique with it.

 

 


[WSDL ]

      <xsd:complexType name="ArrayOf_xsd_string">

        <xsd:sequence>

          <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="xsd:string" />

        </xsd:sequence>

      </xsd:complexType>

      <xsd:complexType name="PromoDetails">

        <xsd:sequence>

          <xsd:element name="assetTypes" nillable="true" type="impl:ArrayOf_xsd_string" />

        </xsd:sequence>


[Response message]

               <assetTypes>

                  <assetTypes>Album</ assetTypes >

               </assetTypes>


[Response message How it should be with regard to WSDL]

               <assetTypes>

                  <item>Album</ item >

               </assetTypes>


[Auto generated Proxy code]

        private string[] assetTypesField;

 

        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=1)]

        [System.Xml.Serialization.XmlArrayItemAttribute("item", IsNullable = false)]

        public string[] assetTypes {

            get {

                return this.assetTypesField;

            }

            set {

                this.assetTypesField = value;

                this.RaisePropertyChanged("assetTypes");

            }

        }


[Fixed Proxy code]

        private string[] assetTypesField;

 

        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=1)]

        [System.Xml.Serialization.XmlArrayItemAttribute("assetTypes ", IsNullable = false)]

        public string[] assetTypes {

            get {

                return this.assetTypesField;

            }

            set {

                this.assetTypesField = value;

                this.RaisePropertyChanged("assetTypes");

            }

        }

 


Wednesday, May 07, 2008

The requirements look easy:
We need to monitor the health of the WCF services, availability of the WCF services. Are they up or down?
But we don't want to call operations of the service  because it sometime could change the service internal status and these changes are out of our control.
Some services have special Heartbeat() operation to make the health monitoring easily, but the most have not.
We don't have to check the work status of the web-method. That means we don't care if some underlying services, like SQL databases, don't work and the services available but response with errors. We just want to know are web-services up or down, could they response at all or not. It should be something really easy.
 
Let's start:
I thought this is quite routine task to the service consumers and there should be several routine decisions.
As I know the OpsMngr2007 use something  simple to measure the web-service health.
 
I've asked gurus on the MSDN forums about this.
 
Dan Rigsby proposed:
"A one way Ping() method on the server works well.  If there is an exception, then the channel is broken.  You can have a timer run Ping against the server at some interval.
If this is a duplex callback system you need to be careful.  The server might also need to check if the client is still alive.  You cant have both the servicecontract and callbackcontract have the same named methods, so you will have to rename one of them."
 
Thanks, Dan!
 
I've tried to
      >ping http://text.company.com/adfadfad/asdfadf/adfadfadf.asmx
and
     >ping http://text.company.com/adfadfad/asdfadf/adfadfadf.asmx?wsdl
 
The ping works only for the host name, like
      >ping text.company.com
not for web-service URL
 
It is not what I want.
 
It checks the health of the host, not the web-service.
It does not cover cases with several services on the one host.
It does not cover cases when the host is OK but the service is not response.
 

Islam Eldemery proposed:
"try to subscribe to the events of the communication object (in the client side), so if a service stopped or disconnected you may handle the fault event.. (remember that it can only fault once).

      proxy.InnerChannel.Faulted +=
new EventHandler(InnerChannel_Faulted);

or
      proxy.InnerDuplexChannel.Faulted += new EventHandler(InnerDuplexChannel_Faulted);

see my example of handling a service in a chat application
http://www.codeproject.com/KB/IP/WCFWPFChatRoot.aspx
if this is a duplex communication, to handle the service on the service side, try to check every time on each callback object you have, to see if someone has been aborted or not before you using it (may be a client disconnect for a network failure.. etc.)"

Islam, thanks for response!

 Unfortunately with this technique we can intercept only errors after we unsuccessfully call the service operation, right?
It is not our case. We want to check the availability not "post mortem" but proactively. For instance, click a button and get health of all services. And we cannot call the service operations, it's one of requirements.
 
Martin16 proposed:
"...
Additional ideas (for IIS/HTTP WCF Services) are 
1) a custom availability operation in your service which checks all resources and gives back a result your web application monitor can parse.
2) enable WCF performance counter and create a monitor on top of that.
3) buy Avicode MP (should provide native WCF Service support)"
 
Thanks for help, Martin16!
 
Yeah, 1) is the Heartbeat() operation. It doesn't work in my case where the services are out of mu control.
For 2) First, we want actively to request the health status not to listen how the service responses to the requests of the other clients.
Second, the WCF performance counters... OK I use them with OpsMng2007 I don't like them very-very much. (It's another story).
3) The third-part utils should use the same APIs we use, not something secret.  I also use OpsMngr2007. But I want to use simple and absolutely open (to me) source code.
 
...
So far so good.
Is it possible to use Mex endpoint or something like HttpRequest to <URL>?wsdl to make sure the service is up?
 
I've got one method from the book "Programming WCF Services" by Juval Lowy (page 71). 
Code Snippet:

   MetadataExchangeClient mexClient =

bool isServiceUp = true;
try
{
  
string address = "http://localhost/MyService.svc?wsdl";new MetadataExchangeClient(new Uri(address), MetadataExchangeClientMode.HttpGet);
   MetadataSet metadata = mexClient.GetMetadata();
// if service down I get the exception
}
   catch (Exception ex)
{
    isServiceUp =
false;
}
 
I catch the Exception like {"Metadata contains a reference that cannot be resolved: "http://localhost/MyService.svc?wsdl"} System.Exception {System.InvalidOperationException}
 
Easy and don't heavy load the service.
P.S.    Please, make sure you've read good comment by Islam Eldemery below.
========================================================================================

Thursday, May 01, 2008

WCF: values disappeared in response: derived classes and serialization/deserialization order error
 
This is a second article about errors with getting data from  the web-services.
"WCF: Deserialization error, the response elements disappeared" ( http://geekswithblogs.net/LeonidGaneline/archive/2008/04/01/wcf-deserialization-error-the-response-elements-disappeared.aspx )
First time the whole elements disappeared from the response messages without any errors. Now only values of the elements disappeared.
 
We got a very strange error.
 
Our client code to one of the third-part web-service could not get the values from the response message.
 
Investigation given us such picture:
The response class has a base class. And the disappeared values are exactly from properties of this class. See the client proxy code that was generated by Visual Studio (Pict.1). Nothing wrong with it.
If we look at the wsdl that was the source for this proxy code (Pict.2) there is nothing wrong too.
The most strange thing is we have the right values in the response message (Pict.3). The errorCode and errorMessage elements have values but then we lost them. We can get them in the code (Pict.4). The output is on Pict.5.
How? Why?
The base class properties are the errorCode and errorMessage, the derived class property is the crn.
The question is in what order those two kind of properties serialize to the elements of the Xml message and then deserialize back to the class properties?
If service and client make serialization and deserialization in the "stack-like" order then everything is OK.
We see that service serialize the derived class properties first and the base class properties last (See Pict.3.1). What about our client? The client is waiting the message with different order of elements (see Pict.3.2)
And this is the source of the problem!
 

In the "Data Member Order " article in the MSDN Library ( http://msdn.microsoft.com/en-us/library/ms729813.aspx ) we see:
 
"...The basic rules for data ordering include:
If a data contract type is a part of an inheritance hierarchy, data members of its base types are always first in the order..."
 
And there is no way to change this behaviour.
 
That's exactly how my client proxy is working. It is waiting the base class properties on the first place and have not get them, and because these properties have minOccurs="0" and nillable="true" attributes the proxy just decided that Xml message does not have properties at all and silently goes on to the first derived class property.
Unfortunately the third-part service uses the opposite order (it uses a java Axis2 service), data members of its base types are always last in the order in the serialized Xml messages.
BTW Here (http://www.onjava.com/pub/a/onjava/excerpt/JavaRMI_10/index.html?page=4) is mentioned that Java uses the same algorithm as WCF. Why does this consuming service use the opposite order? I have no idea.
Jeff W. Barnes in (http://jeffbarnes.net/portal/blogs/jeff_barnes/archive/2007/05/08/wcf-serialization-order-in-data-contracts.aspx) mentioned thet there is the solution but does not give it.
 
Is it possible to change the proxy code on my side to follow the service order? I don't know such options. Seems the WCF-classes where the whole deserialization occurs cannot be tuned up to change this order. Look one more time to the wsdl code (Pict.2). There is nothing about this order, ther is only the complexType the AddNewCreditCardResponse with the extension base="ax21:ResponseData".
Seems the only way to fix the problem is to change the auto generated code for the response message classes and force the right order. (Pict.6) OK from the point of view of WCF it is a wrong code, but what else we could do in this situation?
 
After these changes we've got the right result (see Pict.7).
 
 
 
=======================================================================
[Pict.1: autogenerated proxy code]
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://data.transaction.com/xsd")]
    public partial class AddNewCreditCardResponse : ResponseData {
       
        private string crnField;
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
        public string crn {
            get {   return this.crnField; }
            set { this.crnField = value; }
        }
    }
 ...
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(AddNewCreditCardResponse))]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://data.transaction.com/xsd")]
    public partial class ResponseData {
       
       private string errorCodeField;
       [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
        public string errorCode{
            get { return this.errorCodeField; }
            set {  this.errorCodeField= value; }
       }
 
        private string errorMessageField;
       [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
        public string errorMessage{
            get { return this.errorMessageField; }
            set {  this.errorMessageField= value; }
       }
    }
 

[Pict.2: wsdl code]
    <xs:complexType name="AddNewCreditCardResponse">
        <xs:complexContent mixed="false">
          <xs:extension base="ax21:ResponseData">
            <xs:sequence>
              <xs:element minOccurs="0" name="crn" nillable="true" type="xs:string" />
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
 ...
      <xs:complexType name="ResponseData">
        <xs:sequence>
          <xs:element minOccurs="0" name="errorCode" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="errorMessage" nillable="true" type="xs:string" />
        </xs:sequence>
      </xs:complexType>...
 

[Pict.3.1: original response message]
 ...
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
       <ns:addNewCreditCardResponse xmlns:ns="http://service.transaction.com">
   <ns:return type="com.transaction.data.AddNewCreditCardResponseData" xmlns:ax21="http://data.transaction.com/xsd">
      <ax21:crn/>
      <ax21:errorCode>TXN056</ax21:errorCode>
      <ax21:errorMessage>Process auth with create profile error</ax21:errorMessage>
   </ns:return>
       </ns:addNewCreditCardResponse>
    </soapenv:Body>
 </soapenv:Envelope>
 
[Pict.3.2: response sample with "WCF" order]
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
       <ns:addNewCreditCardResponse xmlns:ns="http://service.transaction.com">
   <ns:return type="com.transaction.data.AddNewCreditCardResponse" xmlns:ax21="http://data.transaction.com/xsd">
      <ax21:errorCode>TXN0544</ax21:errorCode>
      <ax21:errorMessage>Process authentification with profile error</ax21:errorMessage>
      <ax21:crn/>
  </ns:return>
       </ns:addNewCreditCardResponse>
    </soapenv:Body>
 </soapenv:Envelope>
 
[Pict.4: test code]
 ...
 Transaction_Ref.TransactionSvcClient client = new TestTxsServiceConsoleApplication.Transaction_Ref.TransactionSvcClient ("TransactionSvcSOAP11port_http");
 
 Transaction_Ref.addNewCreditCardResponse addNewCreditCardResponse = client.addNewCreditCard(...);
 Console.WriteLine("crn: [{0}]", (addNewCreditCardResponse.crn == null ? "null" : addNewCreditCardResponse.crn));
 Console.WriteLine("errorCode: [{0}]", (addNewCreditCardResponse.errorCode == null ? "null" : addNewCreditCardResponse.errorCode));
 Console.WriteLine("errorMessage: [{0}]", (addNewCreditCardResponse.errorMessage == null ? "null" : addNewCreditCardResponse.errorMessage));
 ...
 

[Pict.5: output with original proxy code]
 crn: []
 errorCode: [null]
 errorMessage: [null]
 

[Pict.6: changed proxy code]
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://data.transaction.com/xsd")]
    public partial class AddNewCreditCardResponse {
       
        private string crnField;
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
        public string crn {
            get { return this.crnField; }
            set {  this.crnField = value; }
       }
 
        private string errorCodeField;
       [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
        public string errorCode{
            get { return this.errorCodeField; }
            set {  this.errorCodeField= value; }
       }
 
        private string errorMessageField;
       [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
        public string errorMessage{
            get { return this.errorMessageField; }
            set {  this.errorMessageField= value; }
       }
 ...
 

[Pict.7: output with changed proxy code]
 crn: []
 errorCode: [TXN0544]
 errorMessage: [Process authentification with profile error]
=========================================
Please, give me a feedback!

Tuesday, April 29, 2008

The message audit can be implemented by BizTalk Tracking (BizTalkDTADb) database.
But there is one big "But". This database has predefined, undescribed structure, it should be used only by special BizTalk tools as HAT. We cannot change the audit points, cannot freely create user queries, cannot change structure of this database.
 
It is not so hard to create the custom audit, it is the standard practice to make the custom audit database and gather data for it from the BizTalk application with additions for the Orchestrations.
 
It is good practice to use some standard for the audit architecture. Here I give you two of them.
They are pretty easy and repeat the "Generic Error handling" pattern. They use the Direct port subscription.
  
I. One audit send port, the audit messages are created in different ways. All audit messages have the same message type. The Audit send port is subscribed to the one audit message type.
II. One audit send port with set of the maps, the audit messages are created by these maps.The Audit send port group is subscribed to the all audited message type.
 
We create the standard audit message type; send all audit messages in all audit points to the Direct send port shape; create the Direct send port with subscription to this audited message type. That is all.
[The audit points are the all audited milestones as receiving/sending the message; transforming the message; routing the message , etc.]
 
ToDo list:
  1. Create the generic_audit schema. It can, for example, include elements: "Operation datetime", "Operation type"(Send/Receive/...), "Original message parameter (like File Name)", "Success/Fail status", "My_Specific_parameter" etc.
  2. Create simple maps to produce the generic_audit schema from all other messages. It is not necessarily all audit parameters be mapped from the source message. Some of them might be produced inside map or expressions, for example, the "Operation datetime" parameter.
  3. Create the Audit Send Direct port with these maps in the entry. Make filters for all audited message types, i.e. subscribe to all these message types.
  4. If we want to save the audited messages in the database: Create the Audit database. The simplest database might be with one table and one stored procedure to fill-in this table.
 FYI You can see in MSDN forum (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2452186&SiteID=1) a comment of Kent Weare [BizTalk MVP] about using BAM for auditing:

"...On at least a couple of occasions I have heard MS employees endorse BAM for auditing.  We brought a Microsoft consultant to review our architecture and design with respect to auditing.  He suggested we use BAM for this purpose.  Note he did not endorse message body tracking inside of BAM.  The other place that I have seen it endorsed is at TechEd at one of Darren Jefford's sessions.  
Without a doubt building up the required BAM infrastructure is not a trivial task(especially in an enterprise scenario).  Keeping things simple is often the best solution, so I do think that you have brought up some valid points. ..."

One more discussion about using HAT for tracking messages is here (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1991237&SiteID=1).

Sunday, April 27, 2008

" ...I have published an orchestration as a web service and consumed it from an aspx page. now, how do I see if I triggered the orchestration and how and where do I get the output (transformed message of the orchestration)? ..."
It is a very common question, how to debug the BizTalk applications.
Have you ever tried to use the BizTalk Orchestration Debugger? So painful experience. Never see the BizTalk developer who is using it in real work.
 
Test port is a port with the filter expression (http://msdn2.microsoft.com/en-us/library/aa578042.aspx, http://msdn2.microsoft.com/en-us/library/aa547903.aspx). This expression creates the subscription to the message you interested in.
All sent and received messages go through the MessageBox. When they pass MessageBox you can create additional subscription to these messages and intercept copies of these messages.
The subscription can be to the message type or to the publisher parameters like Receive port name.
This technique has great benefits:
  • The direct test send ports do not disturb the original message flow (excluding the rare case when all main subscriptions to the debugged message have got unenlisted).
  • They can be easily switch on/off.
As a matter of fact I use two methods on the regular basis. (The second one is the old good Trace.WriteLine(..) with DebugView.exe as a receiver of the debug output.) That means I always create the orchestrations with the Expression shapes (for Trace.WriteLine)) after all message receives/transformations, in the begin/end all branches, plus I create the test send ports for almost ALL messages.
 
Yes, for ALL output messages.
It is easy and fast to create the test send ports in the binding file without using UI.
And I always deploy these test ports to the production. It saved me a lot of time in deployment and maintain.

Friday, April 25, 2008

WCF: Contract name is inconsistent on the client side.

Sometimes we’ve got a very clear fault message:    

 

    <faultstring xml:lang="en-US">Could not find default endpoint element that references contract 'ServiceProvider_configuration_Ref.ConfigurationServicePortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.</faultstring>
         <detail>
            <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
               <HelpLink i:nil="true"/>
               <InnerException i:nil="true"/>
               <Message>Could not find default endpoint element that references contract 'ServiceProvider_configuration_Ref.ConfigurationServicePortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.</Message>
….

It means two things do not conform each other:

1)      The contract attribute in the endpoint element of the config file:

   <endpoint address="https://ie-services-configuration.ServiceProvider.com"

binding="customBinding" bindingConfiguration="customBinding_Configuration"    contract="MyCompany.MyProject.ServiceProvider_configuration_Ref.ConfigurationServicePortType"

      name="ConfigurationServiceHttpPort" />

 

2)       And ConfigurationName property of the ServiceContract attribute in the proxy code. It usually generated by Add Service Reference wizard and placed in the hidden file the Reference.cs

     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]

    [System.ServiceModel.ServiceContractAttribute(
Namespace="http://ws.ServiceProvider.com", ConfigurationName="ServiceProvider_configuration_Ref.ConfigurationServicePortType")]

    public interface ConfigurationServicePortType {

 

How I could get this situation? Very easily. For instance when I am editing my .config file with the Microsoft Service Configuration Editor and selecting to fix my endpoint -> contract name. I choose the dll with the definition of the service contract and there we go! It shows me not the ServiceProvider_configuration_Ref.ConfigurationServicePortType but MyCompany. MyProject.ServiceProvider_configuration_Ref.ConfigurationServicePortType and this creates the error mentioned above.

 

We fix this error easily by changing the config file. Of course we can change the Reference.sc but it is generated be wizard and after updating this reference the error appears again.

 

Is it a whole story? Nope. It is more interesting.

 

Say we have the source code for this Web-service. Then we are creating the client for this Web-service. We are waiting that the full name of the service class should be the same in the service source code and in the client proxy code. It’s wrong! It is completely wrong.

That means the “loose coupling” J All the client could get from the service in terms of data definition is the metadata: one or many wsdl-s and schemas (xsd).  Inside this is the contract name. Usually it is the name of service interface or, if you apply the [ServiceContract] right to the service class, the service class name. The namespaces of the service, data, etc. contracts do not passed by the metadata! When one of the client tools generates the proxy code it usually adds some new namespace. For example the Visual Studio adds the Default namespace parameter from the project properties.

What about the service class name? The metadata passes the name under the [ServiceContract] attribute. And the client tool that generates the proxy code does not know is it the name of the interface or the name of the class. Then is just creates the interface with this name and with the [ServiceContract] attribute. Then it creates the class derived from this interface. And this class has auto generated name!

What about the service contract full name?

For instance:

the source code of the web-service:

namespace CMS_Stub {…

 [ServiceContract(
Namespace = " http://ws.ServiceProvider.com ")]

public interface ICMS_Stub

public class CMS_StubService : ICMS_Stub

 

the client proxy code:

namespace MyCompany. MyProject.ServiceProvider_configuration_Ref {…

[ServiceContract(
Namespace = " http://ws.ServiceProvider.com ",
ConfigurationName="ServiceProvider_configuration_Ref.ICMS_Stub")]

public interface ICMS_Stub

public class CMS_StubClient: ICMS_Stub

 

And what we see in the contract attribute in the endpoint element of the client config file?

  • CMS_Stub.ICMS_Stub?
  • CMS_Stub.CMS_StubService?
  • MyCompany.MySolution.MyProject.DownloadUri.ServiceProvider_configuration_Ref.ICMS_Stub?
  • MyCompany.MySolution.MyProject.DownloadUri.ServiceProvider_configuration_Ref.CMS_StubClient?
  • ServiceProvider_configuration_Ref.ICMS_Stub?

Yes, you are right, the last one, the ConfigurationName of the ServiceContract.