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 5980097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:45:11+00:00 2026-05-22T21:45:11+00:00

I am trying to get my webservice to reply with a particular form of

  • 0

I am trying to get my webservice to reply with a particular form of XML, which I thought I could do with just putting the data in a string and returning this to the webpage.

I am trying to return:

<tradeHistory><trade TradeId="1933" ExtId="1933" instrument="EUA" quantity="1500" setType="Escrow" TradeDate="12/02/2010" DeliveryDt="13/02/2010" PaymentDt="12/02/2010" type="BUY" pricePerUnit="6.81" GrossConsid="10320" currency="EUR"/></tradeHistory>

But when I return the string I’m getting:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;tradeHistory&gt;&lt;trade tradeid="1933" ExtId="1933" Instrument="EUA" quantity"1500" setType="Escrow" TradeDate="24/05/2011" DeliveryDt="25/05/2011" PaymentDt="25/05/2011" type"BUY" pricePerUnit="6.81" GrossConsid="10320" currency="EUR" /&gt;&lt;tradeHistory&gt</string>

Any ideas on how I can achieve this goal? It would be nice not to have the tag but I can live with that but the issue I have is that its not formatting the string correctly its reading the opening and closing tags as special characters

My Service is:

<ServiceContract(Namespace:="")>
Public Interface ITradePortal

<WebGet(UriTemplate:="Reporting/GetClientTrades/{ClientID}")>
    <OperationContract()>
    Function GetClientTrades(ByVal ClientID As String) As String
End Interface

My implementation is:

<ServiceBehavior(ConcurrencyMode:=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode:=InstanceContextMode.Single, _
Namespace:="")>
<XmlSerializerFormat()>

and my config file:

<services>
            <service behaviorConfiguration="Default" name="CFP_Web_Lib.TradePortal">
              <host>
                <baseAddresses>
                  <add baseAddress="http://localhost:8686/TradePortal"/>
                </baseAddresses>
              </host>
                <endpoint address="" binding="webHttpBinding"
                     contract="CFP_Web_Lib.ITradePortal"
                          behaviorConfiguration="web"
                     />
              <endpoint address="Operations/" binding="wsDualHttpBinding"
                   contract="CFP_Web_Lib.ITradeOperations"/>
                   </service>
        </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IPubSubService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsDualHttpBinding>
      <mexHttpBinding>
        <binding name="NewBinding0" />
      </mexHttpBinding>
    </bindings>
  • 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-22T21:45:11+00:00Added an answer on May 22, 2026 at 9:45 pm

    The default return format is XML, so when your operation returns String, it will be formatted as XML – with the string content inside the element. The easiest way to return anything would be to use the raw programming model. Your operation would look something like this:

    <WebGet(UriTemplate:="Reporting/GetClientTrades/{ClientID}")> _
    <OperationContract()> _
    Function GetClientTrades(ByVal ClientID As String) As Stream
    

    And the implementation:

    Function GetClientTraces(ByVal ClientID As String) As Stream Implements ITradePortal.GetClientTraces
        Dim result as String = "<tradeHistory>...</tradeHistory>"
        WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml" ' or anything you need
        return new MemoryStream(Encoding.UTF8.GetBytes(result))
    End Function
    

    Another option, if you don’t want to deal with Streams, is to change the return type to XmlElement (or XElement). That is written out “as is”, so you can return arbitrary XML.

    Yet another option is to create classes to hold that data. The TradeHistory class would hold a reference to a “Trade” instance, and the Trade class would have many fields declared with the attribute. The operation would then have a return type of TradeHistory.

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

Sidebar

Related Questions

I'm trying to get data from a webservice, returning just one result, the number
In C#, I am trying to get call a webservice which returns an XML
When trying to get some data on my android client from my webservice (running
Im trying to make a webservice in ASP.NET and get the data in a
I am trying to get the result of the following json webservice https://mtgox.com/code/data/getDepth.php into
I am trying to get data from WebService for my Ipad App. To do
I am trying to get the data from the webservice and create dynamic custom
I'm trying to post some data to a webservice and utilize the XML data
I am trying to get a WCF webservice running which will participate in distributed
When trying get in memcache client, getting the below excepton. Caused by: java.io.IOException: com.fet.myclass.webservice.data.DataList

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.