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)]