473,473 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Changing the XML element name of the generated SOAP result in WCF

Hello,

I need to implement a webservice based on an XSD, so I'm stuck with
the names someone else thought up. I wanted to implement this
webservice in WCF to maximize our options should we wish to change
stuff or add stuff.
The problem I run into is that I need to give the element that
contains the result of a function a certain name, but I can't find out
how.

I have a function Bar() and it returns a class called Foo. Foo
contains just a string called Message. So this should be:
class Foo{ public string Message; }

Foo Bar();

So far I got the resulting SOAP XML to be:
<BarResponse>
<BarResult>
<Message/>
</BarResult>
</BarResponse>

But I need it to be:
<BarResponse>
<MyFooBarResult>
<Message/>
</MyFooBarResult>
</BarResponse>

Because of other problems with the correct nesting of array elements
I'm using the XmlSerializer in stead of the ObjectSerializer on my
webservice. So I figured I could just tack an attribute on the
webservice like I could in ASMX webservices: [return:
XmlElement("MyFooBarResult")], but that doesn't seem to work.

I also already added an [XmlRoot(ElementName = "MyFooBarResult")]
attribute to the Foo class, but that also doesn't seem to make a
difference.

Any ideas?

Thanks.

Jeroen-bart Engelen
Sep 10 '08 #1
2 3235


"Jeroen-bart Engelen" wrote:
Hello,

I need to implement a webservice based on an XSD, so I'm stuck with
the names someone else thought up. I wanted to implement this
webservice in WCF to maximize our options should we wish to change
stuff or add stuff.
The problem I run into is that I need to give the element that
contains the result of a function a certain name, but I can't find out
how.

I have a function Bar() and it returns a class called Foo. Foo
contains just a string called Message. So this should be:
class Foo{ public string Message; }

Foo Bar();

So far I got the resulting SOAP XML to be:
<BarResponse>
<BarResult>
<Message/>
</BarResult>
</BarResponse>

But I need it to be:
<BarResponse>
<MyFooBarResult>
<Message/>
</MyFooBarResult>
</BarResponse>

Because of other problems with the correct nesting of array elements
I'm using the XmlSerializer in stead of the ObjectSerializer on my
webservice. So I figured I could just tack an attribute on the
webservice like I could in ASMX webservices: [return:
XmlElement("MyFooBarResult")], but that doesn't seem to work.

I also already added an [XmlRoot(ElementName = "MyFooBarResult")]
attribute to the Foo class, but that also doesn't seem to make a
difference.

Any ideas?

Thanks.

Jeroen-bart Engelen
Hello,

we have the same problem. Do you have any answers by now?

Thanks

rasc-d
Oct 14 '08 #2
I'm also looking for this answer, any ideas??

"rasc-d" wrote:
>

"Jeroen-bart Engelen" wrote:
Hello,

I need to implement a webservice based on an XSD, so I'm stuck with
the names someone else thought up. I wanted to implement this
webservice in WCF to maximize our options should we wish to change
stuff or add stuff.
The problem I run into is that I need to give the element that
contains the result of a function a certain name, but I can't find out
how.

I have a function Bar() and it returns a class called Foo. Foo
contains just a string called Message. So this should be:
class Foo{ public string Message; }

Foo Bar();

So far I got the resulting SOAP XML to be:
<BarResponse>
<BarResult>
<Message/>
</BarResult>
</BarResponse>

But I need it to be:
<BarResponse>
<MyFooBarResult>
<Message/>
</MyFooBarResult>
</BarResponse>

Because of other problems with the correct nesting of array elements
I'm using the XmlSerializer in stead of the ObjectSerializer on my
webservice. So I figured I could just tack an attribute on the
webservice like I could in ASMX webservices: [return:
XmlElement("MyFooBarResult")], but that doesn't seem to work.

I also already added an [XmlRoot(ElementName = "MyFooBarResult")]
attribute to the Foo class, but that also doesn't seem to make a
difference.

Any ideas?

Thanks.

Jeroen-bart Engelen
Hello,

we have the same problem. Do you have any answers by now?

Thanks

rasc-d
Oct 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mike | last post by:
I have a web service being consume by a new client. The WebMethod they are calling is called Process. So in the WSDL I have has 2 elements, Process and ProcessResponse. <s:schema...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
0
by: John Jenkins | last post by:
Hi, any help on this would be greatly apprciated. I have been given a wsdl file from a customer generated by Oracle 10g Web Services tools. When I use wsdl.exe to attempt to produce proxy classes I...
2
by: lprisr | last post by:
Hi, I have double byte characters in the content that I am returning using Web Services. However, the encoding in the xml file returned by Web Services is utf-8 and I am unable to read the...
3
by: GT | last post by:
I have a .NET client that consumes an Axis web service. A change was made recently to the AXIS web service, and ever since then my .NET proxy class has been throwing an InvalidCastException. The...
13
by: Jiho Han | last post by:
Here's the issue. You have a class, Class Person { public int id; public string firstname; public string lastname; }
3
by: jparulan | last post by:
Hi All, I'm using SOAP3.0. I was able to successfully call a WSDL file and get a value properly. But when the WSDL changed to have a MULTIPLE <element name> it was failing. This code works...
2
by: forcey | last post by:
Hi all, I'm writing a SOAP server using the SOAP extension and I need to return an array_map_name_balance, which is defined in a WSDL file like this: <xsd:complexType name="map_name_balance">...
0
by: nappingcub | last post by:
This is my first time coding a web service in .NET and ran into a slight snag that I was hoping that anyone could help me out on. I'm using the generic Hello World web service that is stubbed out on...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.