locked
Soap Header Serialization Error for Custom Soap Header RRS feed

  • Question

  • I have a orchestration which is exposed as a web service -asmx (actually the schema is exposed).
    Both the request and response messages have a custom SOAP header. Everything does work fine till the point where
    as part of our audit strategy, I construct the audit message (which has 2 <any> nodes, one for the header and the other for the body).
    I get this error at runtime:

    Type 'System.Web.Services.Protocols.SoapHeader' in Assembly 'System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

    I know it occurrs when i send the audit message out to the message box(at the send shape) where the audit framework is directly bound. As far as i can tell
    this is because once the message has been sent out to the message box BizTalk cannot persist. Has anyone faced this problem or know any
    workaround for this? I could use a custom pipeline to solve this (should work, haven't tried it though) but again my orchestration does call another process
    which needs the soap header (and that assembly is non serializable and not in our control) so i do have to use an atomic scope where i again face
    the same problem.

    Not that it should matter but for creating the audit message we use a .net assembly which returns an XML Document and takes in the Soap Header string and Soap body
    XML Document.

    Any help is appreciated.

    Thanks
    -Nishant

    Thursday, July 16, 2009 11:40 PM

Answers

  • Could you use the basicHttp binding and call the service using WCF? This would let you get away from the non serializable System.WebServices SoapHeader.

    Here is an article about writing to the WCF message context to send a custom SOAP header: http://msdn.microsoft.com/en-us/library/bb246105(BTS.10).aspx.

    You can also set a SOAP header through a WCF service reference on a BizTalk 2009 project.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Friday, July 17, 2009 2:57 PM
    Moderator

All replies

  • If you are calling any assembly inside your orchestration in a non-atomic scope and the class in your assembly is not serializable then you will get this error. If you are calling an external assembly and you cannot modify it. Create a wrapper class for the class and method which you are calling in the external assembly.

    For this create another Library project and add a class marked as serializable. Create same signature method(s) and in those method(s) call the method which you were calling from your orchestration. Add a reference to your BizTalk project to the assembly of this Library project. Call the newly wrapper method from your orchestration.
    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Friday, July 17, 2009 1:24 AM
  • Could you use the basicHttp binding and call the service using WCF? This would let you get away from the non serializable System.WebServices SoapHeader.

    Here is an article about writing to the WCF message context to send a custom SOAP header: http://msdn.microsoft.com/en-us/library/bb246105(BTS.10).aspx.

    You can also set a SOAP header through a WCF service reference on a BizTalk 2009 project.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Friday, July 17, 2009 2:57 PM
    Moderator