Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 610035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:37:52+00:00 2026-05-13T17:37:52+00:00

I have an object exposed through a web service that is consumed by another

  • 0

I have an object exposed through a web service that is consumed by another system. That system also uses that same WSDL to return back an object on demand to us. I was wondering if it was possible to take that same object and relay it back to a the original object?

I tried to do the following and it wouldn’t actually cast it back with the object populated… Any help would be great!

Thank you!

Note The method code listed below was based off of http://www.dotnetjohn.com/articles.aspx?articleid=173

    public void ConvertBack()
    {
        ThirdParty.Animal animal;
        using (var svc = new ThirdPartySoapClient())
            thirdPartyAnimal = svc.GetAnimal("Identifier");

        var xml = SerializeObject(thirdPartyAnimal, typeof(ThirdParty.Animal));

        var originalAnimal = (OriginalNamespace.Animal)DeserializeObject(xml, typeof(OrginalNamespace.Animal));

        Assert.AreEqual(originalAnimal.Name, animal.Name);
    }


    /// <summary>
    /// Method to convert a custom Object to XML string
    /// </summary>
    /// <param name="pObject">Object that is to be serialized to XML</param>
    /// <param name="typeOfObject">typeof() object that is being passed to be serialized to XML</param>
    /// <returns>XML string</returns>
    public string SerializeObject(object pObject, Type typeOfObject)
    {
        try
        {
            var memoryStream = new MemoryStream();
            var xs = new XmlSerializer(typeOfObject);
            var xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);

            xs.Serialize(xmlTextWriter, pObject);
            memoryStream = (MemoryStream) xmlTextWriter.BaseStream;
            var xmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
            return xmlizedString;
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            return null;
        }
    }

    /// <summary>
    /// Method to reconstruct an Object from XML string
    /// </summary>
    /// <param name="pXmlizedString">XML To Be Converted to an Object</param>
    /// <param name="typeOfObject">typeof() object that is being passed to be serialized to XML</param>
    /// <returns></returns>
    public object DeserializeObject(string pXmlizedString, Type typeOfObject)
    {
        var xs = new XmlSerializer(typeOfObject);
        var memoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString));
        new XmlTextWriter(memoryStream, Encoding.UTF8);
        return xs.Deserialize(memoryStream);
    }

    /// <summary>
    /// To convert a Byte Array of Unicode values (UTF-8 encoded) to a complete String.
    /// </summary>
    /// <param name="characters">Unicode Byte Array to be converted to String</param>
    /// <returns>String converted from Unicode Byte Array</returns>
    private static string UTF8ByteArrayToString(Byte[] characters)
    {
        var encoding = new UTF8Encoding();
        var constructedString = encoding.GetString(characters);
        return (constructedString);
    }

    /// <summary>
    /// Converts the String to UTF8 Byte array and is used in De serialization
    /// </summary>
    /// <param name="pXmlString"></param>
    /// <returns></returns>
    private static Byte[] StringToUTF8ByteArray(string pXmlString)
    {
        var encoding = new UTF8Encoding();
        var byteArray = encoding.GetBytes(pXmlString);
        return byteArray;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:37:53+00:00Added an answer on May 13, 2026 at 5:37 pm

    When generating the proxy from WSDL there is an option called “/sharetypes” which should solve this problem

    You can use it from the command line tools or in the options area of the “Add Web Service” dialogs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a self-hosted WCF service (v4 framework) that is exposed through a HttpTransport
I have a object that implements the IEditableObject interface exposed on a viewmodel bound
I have a data object -- a custom class called Notification -- that exposes
I have two tables: object that has object_id column and avalues that have object_id
I think I read somewhere that some modules only have object oriented interfaces (
I have to consume a .NET hosted web service from a Java application. Interoperability
I am developing a Java web application that bases it behavior through large XML
I have a C++ library (Win32) that fills some fields in a web page
I have created a class called BasePage which inherits System.Web.UI.Page. On this page I've
I have a few JAX-WS web services hosted on the same server. They use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.