Solved

The type '' was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically

Posted on 2014-11-17
3
1,024 Views
Last Modified: 2016-02-16
Hi,

When my Soap Web Service is called, it does everything what it should but generates the following soap error message:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Receiver</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type BBTSerenaIntegration.ZMFWebservice_PackageLifeCycleServices.response was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write4_Type(String n, String ns, Type o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write5_Header(String n, String ns, Header o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write7_Output(String n, String ns, Output o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write27_ZMF_FreezePackageResponse(Object[] p)
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer25.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
   at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
   at System.Web.Services.Protocols.WebServiceHandler.Invoke()
   --- End of inner exception stack trace ---</soap:Text>
         </soap:Reason>
         <soap:Detail/>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

I have tried to add the includes as suggested in the error message but both entries didn't solve the issue:
[XmlInclude(typeof(ZMFWebservice_PackageLifeCycleServices.response))]
[SoapInclude(typeof(ZMFWebservice_PackageLifeCycleServices.response))]

In the attachments you can find the Soap Web Service (BBTSerenaIntegration.asmx.cs) and the Operations class (ZMFOperation.cs) which is being called by the Soap Web Service.
ZMFWebservice_PackageLifeCycleServices is a reference to a Soap Web Service.

Thanks in advance for all the assistance.

Regards,

Tomi
BBTSerenaIntegration.asmx.cs
ZMFOperations.cs
soap-error.txt
0
Comment
Question by:tcorigli
3 Comments
 
LVL 4

Accepted Solution

by:
ItWorked earned 500 total points
ID: 40449501
I guess you have done wrong!

    [SoapInclude(typeof(ZMFWebservice_PackageLifeCycleServices.response))]
    public Output freezePackage(String package)

Open in new window


Attribute [SoapInclude] is not required for internal class operation.Check here.

What I suggest instead,
Place a break point at return statement at below line of code.
    ZMFOperations zmfOperations = new ZMFOperations();
    Output output = zmfOperations.freezePackage(package);
    return output;

Open in new window


Check what's
Type

Open in new window

of "output" object (you can use object.GetType() to identify that) and add below line of code in BBTSerenaIntegration.asmx.cs
    [SoapInclude(typeof(TYPE_THAT_YOU_RECEIVED_WHILE_DEBUGING))]
    public Output ZMF_FreezePackage(String package)

Open in new window


This shall work. Let me know if issue still persist.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now