Webservice and browser

G

Guest

Hi,
I have a small HTML page which posts requests to a web service. I am
using a IFRAME for that so that the entire page wont reload. All is working
fine except that the respose from the web service changes once it reaches the
client. i.e it adds all javascript for handling + and - events when an xml
file is rendered. I need to avoid that and I need only the pure XML response
from the web service. I added a SoapExtension on my web service and found
that the servcie is working fine and respose is
-----SoapResponse at 7/18/2005 2:35:29 PM
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getnameResponse
xmlns="http://tempuri.org/"><getnameResult>Hello</getnameResult></getnameResponse></soap:Body></soap:Envelope>
but whe is reaches the browser
its somethisng like this
**********<HEAD>
<STYLE>BODY{font:x-small 'Verdana';margin-right:1.5em}
..c{cursor:hand}
..b{color:red;font-family:'Courier New';font-weight:bold;text-decoration:none}
..e{margin-left:1em;text-indent:-1em;margin-right:1em}
..k{margin-left:1em;text-indent:-1em;margin-right:1em}
..t{color:#990000}
..xt{color:#990099}
..ns{color:red}
..dt{color:green}
..m{color:blue}
..tx{font-weight:bold
..db{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;border-left:1px solid #CCCCCC;font:small Courier}
..di{font:small Courier}
..d{color:blue}
..pi{color:blue
..cb{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;font:small Courier;color:#888888}
..ci{font:small Courier;color:#888888}
PRE{margin:0px;display:inline}</STYLE>

<SCRIPT><!--
function f(e){
if (e.className=="ci"){if (e.children(0).innerText.indexOf("\n")>0)
fix(e,"cb");}
if (e.className=="di"){if (e.children(0).innerText.indexOf("\n")>0)
fix(e,"db");}
e.id="";
}
function fix(e,cl){
e.className=cl;
e.style.display="block";
j=e.parentElement.children(0);
j.className="c";
etc etc and then the actual response.

How to avoid this ?
Any Suggestions?
 
N

Nicholas Paldino [.NET/C# MVP]

Ravi,

The problem here is that the mime type of the returned content is
text/xml, so IE shows you that view by default. In order to get around
that, I would use the XmlHttpRequest (I think that is the name) object on
the client to post your request and get your response. You can then take
the XML and set the document content to that XML document (in text form, of
course).

This would also allow you to get rid of the IFRAME as well.

If you don't want to use that on the client side, I would create another
page which will forward the call to the web service for you, and set the
content type on the response to "text/plain" instead of "text/xml" (you
shouldn't modify the original web service to do this). IE might still
process it as XML though, since it sniffs content for types in case the
headers are wrong. However, I believe there are headers you can set to tell
IE to not do that.

Hope this helps.
 
G

Guest

Thanks. That really helped. I'll have a look at the options specified.
-- Ravi

Nicholas Paldino said:
Ravi,

The problem here is that the mime type of the returned content is
text/xml, so IE shows you that view by default. In order to get around
that, I would use the XmlHttpRequest (I think that is the name) object on
the client to post your request and get your response. You can then take
the XML and set the document content to that XML document (in text form, of
course).

This would also allow you to get rid of the IFRAME as well.

If you don't want to use that on the client side, I would create another
page which will forward the call to the web service for you, and set the
content type on the response to "text/plain" instead of "text/xml" (you
shouldn't modify the original web service to do this). IE might still
process it as XML though, since it sniffs content for types in case the
headers are wrong. However, I believe there are headers you can set to tell
IE to not do that.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ravi said:
Hi,
I have a small HTML page which posts requests to a web service. I am
using a IFRAME for that so that the entire page wont reload. All is
working
fine except that the respose from the web service changes once it reaches
the
client. i.e it adds all javascript for handling + and - events when an xml
file is rendered. I need to avoid that and I need only the pure XML
response
from the web service. I added a SoapExtension on my web service and found
that the servcie is working fine and respose is
-----SoapResponse at 7/18/2005 2:35:29 PM
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getnameResponse
xmlns="http://tempuri.org/"><getnameResult>Hello</getnameResult></getnameResponse></soap:Body></soap:Envelope>
but whe is reaches the browser
its somethisng like this
**********<HEAD>
<STYLE>BODY{font:x-small 'Verdana';margin-right:1.5em}
.c{cursor:hand}
.b{color:red;font-family:'Courier
New';font-weight:bold;text-decoration:none}
.e{margin-left:1em;text-indent:-1em;margin-right:1em}
.k{margin-left:1em;text-indent:-1em;margin-right:1em}
.t{color:#990000}
.xt{color:#990099}
.ns{color:red}
.dt{color:green}
.m{color:blue}
.tx{font-weight:bold}
.db{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;border-left:1px
solid #CCCCCC;font:small Courier}
.di{font:small Courier}
.d{color:blue}
.pi{color:blue}
.cb{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;font:small
Courier;color:#888888}
.ci{font:small Courier;color:#888888}
PRE{margin:0px;display:inline}</STYLE>

<SCRIPT><!--
function f(e){
if (e.className=="ci"){if (e.children(0).innerText.indexOf("\n")>0)
fix(e,"cb");}
if (e.className=="di"){if (e.children(0).innerText.indexOf("\n")>0)
fix(e,"db");}
e.id="";
}
function fix(e,cl){
e.className=cl;
e.style.display="block";
j=e.parentElement.children(0);
j.className="c";
etc etc and then the actual response.

How to avoid this ?
Any Suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top