473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Webservice returns void

Hi,

I have a web service that returns void but internally writes data to
context as shown below:

------------------------------------------------------------------------------------------------------------------------------------------------------
[WebMethod( Description = "Gets the configuration" )]
public void GetChanges( string guid )
{
try
{
string configData = "<test></test>";
byte[] utf8 = Encoding.UTF8.GetBytes( configData );

Context.Response.ContentType = "text/xml";
Context.Response.BinaryWrite( utf8 );
Context.Response.Flush();
}
catch( Exception ex )
{
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------

Now when I utilize this method in my C# code, I get following error:
Response is not well-formed XML.
------------------------------------------------------------------------------------------------------------------------------------------------------
localhost.WebServiceTest asrv = new
TestMSWebService.localhost.WebServiceTest();
asrv.GetChanges("DF61B16D-61AB-4644-91BB-0F0441D6AB43");
------------------------------------------------------------------------------------------------------------------------------------------------------

How do I get the response from the webservice?

Please let me know.

Thanks in advance,
PSI
Jun 27 '08 #1
4 3631
On Jun 26, 1:58 am, Pramod <ipra...@gmail.comwrote:
Hi,

I have a web service that returns void but internally writes data to
context as shown below:

------------------------------------------------------------------------------------------------------------------------------------------------------
[WebMethod( Description = "Gets the configuration" )]
public void GetChanges( string guid )
{
try
{
string configData = "<test></test>";
byte[] utf8 = Encoding.UTF8.GetBytes( configData );

Context.Response.ContentType = "text/xml";
Context.Response.BinaryWrite( utf8 );
Context.Response.Flush();
}
catch( Exception ex )
{
}}

------------------------------------------------------------------------------------------------------------------------------------------------------

Now when I utilize this method in my C# code, I get following error:
Response is not well-formed XML.
------------------------------------------------------------------------------------------------------------------------------------------------------
localhost.WebServiceTest asrv = new
TestMSWebService.localhost.WebServiceTest();
asrv.GetChanges("DF61B16D-61AB-4644-91BB-0F0441D6AB43");
------------------------------------------------------------------------------------------------------------------------------------------------------

How do I get the response from the webservice?

Please let me know.

Thanks in advance,
PSI
if you want to return binary data, would not something other than a
web service be better? possibly an aspx or ashx page that does the
binary write to the return stream?

or if you don't need a binary write (because your test data is in fact
just text) why not return a string from the web service and deal with
that at the other end?
Jun 27 '08 #2
On Jun 26, 6:45*am, densial <dens...@gmail.comwrote:
On Jun 26, 1:58 am, Pramod <ipra...@gmail.comwrote:


Hi,
I have a web service that returns void but internally writes data to
context as shown below:
---------------------------------------------------------------------------*---------------------------------------------------------------------------
[WebMethod( Description = "Gets the configuration" )]
public void GetChanges( string guid )
{
* * * * try
* * * * {
* * * * * * * * string configData = "<test></test>";
* * * * * * * * byte[] utf8 = Encoding.UTF8.GetBytes(configData );
* * * * * * * * Context.Response.ContentType = "text/xml";
* * * * * * * * Context.Response.BinaryWrite( utf8 );
* * * * * * * * Context.Response.Flush();
* * * * }
* * * * catch( Exception ex )
* * * * {
* * * * }}
---------------------------------------------------------------------------*---------------------------------------------------------------------------
Now when I utilize this method in my C# code, I get following error:
Response is not well-formed XML.
---------------------------------------------------------------------------*---------------------------------------------------------------------------
localhost.WebServiceTest asrv = new
TestMSWebService.localhost.WebServiceTest();
asrv.GetChanges("DF61B16D-61AB-4644-91BB-0F0441D6AB43");
---------------------------------------------------------------------------*---------------------------------------------------------------------------
How do I get the response from the webservice?
Please let me know.
Thanks in advance,
PSI

if you want to return binary data, would not something other than a
web service be better? possibly an aspx or ashx page that does the
binary write to the return stream?

or if you don't need a binary write (because your test data is in fact
just text) why not return a string from the web service and deal with
that at the other end?- Hide quoted text -

- Show quoted text -

Sorry to say but we cannot change the Webservice....

Thanks
PSI
Jun 27 '08 #3
On Jun 26, 5:54 pm, Pramod <ipra...@gmail.comwrote:
On Jun 26, 6:45 am, densial <dens...@gmail.comwrote:
On Jun 26, 1:58 am, Pramod <ipra...@gmail.comwrote:
Hi,
I have a web service that returns void but internally writes data to
context as shown below:
---------------------------------------------------------------------------*---------------------------------------------------------------------------
[WebMethod( Description = "Gets the configuration" )]
public void GetChanges( string guid )
{
try
{
string configData = "<test></test>";
byte[] utf8 = Encoding.UTF8.GetBytes( configData );
Context.Response.ContentType = "text/xml";
Context.Response.BinaryWrite( utf8 );
Context.Response.Flush();
}
catch( Exception ex )
{
}}
---------------------------------------------------------------------------*---------------------------------------------------------------------------
Now when I utilize this method in my C# code, I get following error:
Response is not well-formed XML.
---------------------------------------------------------------------------*---------------------------------------------------------------------------
localhost.WebServiceTest asrv = new
TestMSWebService.localhost.WebServiceTest();
asrv.GetChanges("DF61B16D-61AB-4644-91BB-0F0441D6AB43");
---------------------------------------------------------------------------*---------------------------------------------------------------------------
How do I get the response from the webservice?
Please let me know.
Thanks in advance,
PSI
if you want to return binary data, would not something other than a
web service be better? possibly an aspx or ashx page that does the
binary write to the return stream?
or if you don't need a binary write (because your test data is in fact
just text) why not return a string from the web service and deal with
that at the other end?- Hide quoted text -
- Show quoted text -

Sorry to say but we cannot change the Webservice....

Thanks
PSI
hmm... ok well you could try executing the web service directly rather
then consuming it. when you consume it it gets all error checked and
such, but if you try calling it (never tried myself, just thinking)
maybe through webclient? you could get the response stream from that?
just a thought, not sure how to do it but sure it can be done.

cheers,
denz.
Jun 27 '08 #4

"Pramod" <ip*****@gmail.comwrote in message
news:2f**********************************@f24g2000 prh.googlegroups.com...
Hi,

I have a web service that returns void but internally writes data to
context as shown below:

------------------------------------------------------------------------------------------------------------------------------------------------------
[WebMethod( Description = "Gets the configuration" )]
public void GetChanges( string guid )
{
try
{
string configData = "<test></test>";
byte[] utf8 = Encoding.UTF8.GetBytes( configData );

Context.Response.ContentType = "text/xml";
Context.Response.BinaryWrite( utf8 );
Context.Response.Flush();
}
catch( Exception ex )
{
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------

Now when I utilize this method in my C# code, I get following error:
Response is not well-formed XML.
------------------------------------------------------------------------------------------------------------------------------------------------------
Sounds to me like you are getting back a Content, sure, but the .NET method
that catches it doesn't accept it as XML.
Can you see your output anywhere?

Well-formed XML would also have the string
<?xml version="1.0"?>
at minimum. Try creating a new XML file in Visual Studio and see what I
mean.
It creates a "blank" file with the following line ( Visual Studio 2005 ):
<?xml version="1.0" encoding="utf-8"?>
I am not familiar with the Context class, but it appears to let you
construct your own HTTP response, sending a Content-Type: HTTP Header
followed by the content. Your proxy class then is looking for XML, and I
would bet it's strict on accepting only XML with proper headers as such.

Hope this helps, try changing to:

string xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
string configData = "<test></test>";
byte[] utf8 = Encoding.UTF8.GetBytes( xmlHeader + configData );

localhost.WebServiceTest asrv = new
TestMSWebService.localhost.WebServiceTest();
asrv.GetChanges("DF61B16D-61AB-4644-91BB-0F0441D6AB43");
------------------------------------------------------------------------------------------------------------------------------------------------------

How do I get the response from the webservice?

Please let me know.

Thanks in advance,
PSI

Aug 5 '08 #5

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

Similar topics

1
by: Karuppasamy | last post by:
H I have a WebService calling a Method in a Remote Object. The Remote method Returns an Object. This Webservice also returns the same object. All things are working fine when this Web Service is...
0
by: ksams | last post by:
Hi Hope this mail finds you in the best of health and in good sprit. I have a problem with Web Service in a Windows 2000 Advanced Serve Machine. I have a WebService calling a Method in a...
5
by: mtv | last post by:
Hi all, I have the following code: ================================ Webservice side: public class MyWS: WebService { private myLib.DataObject curDataObject;
1
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
3
by: LT_Hassan | last post by:
This is only a model program, because it would take too long to demonstrate the real solution. Anyway, I have 3 projects - ClassLibrary1, ConsoleApplication1 and WebSite1 (which hosts webservice)....
4
by: =?Utf-8?B?TmFkYXYgUG9wcGxld2VsbA==?= | last post by:
Hi everybody, I've got two questions about using the EnableSession property with an ASP.NET WebService: First Question: I'm trying to create a web service with EnableSession=true. I can't...
1
by: =?Utf-8?B?d2R1ZGVr?= | last post by:
I have a web service hosting a WCF library, which works fine but produced a strange signature when interacting with vs 2005/2.0 clients. My method takes 3 strings and returns a bool as below. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.