Web Services

M

M B HONG 20

Hi all-

I am new to web services, so please bear with me. I have to have a web
service (Coded in Visual C#), and I need to have it work with Netscape
7.0 (Mozilla 1.0 I believe). I have it working perfectly with IE (with
the help of webservice.htc), but cannot get it working in Netscape 7.0.
I have read articles on how to access Web Services through Javascript
with SOAP, but I get errors saying that "SOAPCall is undefined", etc.
Does anybody know how to access web service methods in javascript for
Netscape 7.0? Any help would be greatly appreciated. Thanks in
advance.
 
V

VK

I have to have a web service (Coded in Visual C#),
and I need to have it work with Netscape 7.0
(Mozilla 1.0 I believe).

I don't think that you can do it, especially with .htc blocks that you
call "web service" and which is Microsoft "behaviors" in the reality.
It *should* work though on Netscape 8.0 that has its dual-mode property
(so it can act as FF or IE upon the curcumstances). It makes me
suspitius though that you mention C# and .htc blocks in one context.
Could you give a sample HTML/XML page your're calling server-side
blocks from?
 
M

Martin Honnen

M said:
I am new to web services, so please bear with me. I have to have a web
service (Coded in Visual C#), and I need to have it work with Netscape
7.0 (Mozilla 1.0 I believe). I have it working perfectly with IE (with
the help of webservice.htc), but cannot get it working in Netscape 7.0.
I have read articles on how to access Web Services through Javascript
with SOAP, but I get errors saying that "SOAPCall is undefined", etc.
Does anybody know how to access web service methods in javascript for
Netscape 7.0? Any help would be greatly appreciated. Thanks in
advance.

As far as I remember SOAPCall is around since Mozilla 1.0 and thus
should be supported in Netscape 7.0. Do you have code that works with
later Netscape or Mozilla versions but gives the "SOAPCall is undefined"
error in Netscape 7.0? Do you have a URL where the error occurs?
I have no Mozilla 1.0 build here but in the Mozilla 1.1 build I have
SOAPCall is defined.

Of course 7.0 is quite old so it is always a good idea to upgrade (or
get your users to upgrade).
 
M

M B HONG 20

Hey thanks to both of you for your replies.

As for Netscape 7.0, I am aware that WSDL is supported in Netscape
7.1(Mozilla 1.4), but making it work for Netscape 7.0 is a must for me
im afraid. I have read some articles on calling web service methods
from Netscape 7.0 with SOAP, but I get a "SOAPCall is undefined" error
when i try running the script. Basically in my Web Service (C#) i just
have a simple function:

[WebMethod]
public bool ReturnTrue()
{
return true;
}

and in my client side script i have something like:
var soapCall = new SOAPCall();
soapCall.transportURI = ..... etc.

but the error occurs on the top line of the script, which is the
initialization of the SOAPCall. Do I need any sort of plugin or
additional reference to make this work? i used this site for
reference, by the way:
http://devedge-temp.mozilla.org/viewsource/2003/soap/01/index_en.html

regards.
 
M

Martin Honnen

M B HONG 20 wrote:

As for Netscape 7.0, I am aware that WSDL is supported in Netscape
7.1(Mozilla 1.4), but making it work for Netscape 7.0 is a must for me
im afraid. I have read some articles on calling web service methods
from Netscape 7.0 with SOAP, but I get a "SOAPCall is undefined" error
when i try running the script. Basically in my Web Service (C#) i just
have a simple function:

[WebMethod]
public bool ReturnTrue()
{
return true;
}

and in my client side script i have something like:
var soapCall = new SOAPCall();
soapCall.transportURI = ..... etc.

but the error occurs on the top line of the script, which is the
initialization of the SOAPCall. Do I need any sort of plugin or
additional reference to make this work? i used this site for
reference, by the way:
http://devedge-temp.mozilla.org/viewsource/2003/soap/01/index_en.html

The error is odd, I have grabbed a Mozilla 1.0 build and tried new
SOAPCall() and that creates an object.
The user agent string is
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530
and Netscape 7.0 should be some 1.0.1 or 1.0.2 release and thus have
SOAPCall too.
 
M

M B HONG 20

Martin -

Thanks for your reply. You are right, it does work in Netscape 7.0 and
I got the SOAP object to be created. This brings me to another
question though, now that it is working, I can't seem to get the web
service method called. I think there is something wrong with my
syntax. Like i said before, my web service looks like this:

[WebMethod]
public bool SayGoodBye()
{
return false;
}

and my client script looks like this so far:

var soapCall = new SOAPCall(); //which now works, by the way
soapCall.transportURI = "http://localhost/test/Service1.asmx";
soapCall.encode(0, "SayGoodBye", null, 0, null, null, null);
var result = soapCall.invoke();
alert (result.value);


but I keep getting "undefined" instead of "false". I'm pretty sure its
my encode line, can you please tell me what's wrong? The webmethod
does not take any parameters, so i am not sure what to put there (the
last 2 parameters of the encode method). Thanks in advance.

Regards.
 
M

Martin Honnen

M B HONG 20 wrote:

You are right, it does work in Netscape 7.0 and
I got the SOAP object to be created.

Fine, then we have a starting point to work something out.
However when I have tested the interoperability of Mozilla and .NET web
services some while ago I have unfortunately found that Mozilla is able
to understand the SOAP response of a .NET RPC style web service but that
..NET does not understand Mozilla's SOAP requests. But as your example
does not pass anything to the web service it should be possible to get
it to work with Mozilla (but as far as I know only if the service is RPC
style).
So you would need .NET C# code alike

[WebService(Namespace="http://example.com/2005/06/BoolService")]
[SoapRpcService]
public class TestService : WebService {
This brings me to another
question though, now that it is working, I can't seem to get the web
service method called. I think there is something wrong with my
syntax. Like i said before, my web service looks like this:

[WebMethod]
public bool SayGoodBye()
{
return false;
}

and my client script looks like this so far:

var soapCall = new SOAPCall(); //which now works, by the way
soapCall.transportURI = "http://localhost/test/Service1.asmx";

I think you also need to set the action URI e.g.
soapCall.actionURL = "http://example.com/2005/06/BoolService/SayGoodBye";
soapCall.encode(0, "SayGoodBye", null, 0, null, null, null);

That should be
soapCall.encode(
0,
"SayGoodBye"
"http://example.com/2005/06/BoolService",
0,
null,
0,
null
);
where the URL is the one defined for your web service.
var result = soapCall.invoke();
alert (result.value);

It is not that easy that the return value of the invoke call has a value
property. You should first check for an error e.g.
if (result.fault) {
alert(result.fault.faultString);
}
else {
var responseValues = result.getParameters(false, {});
alert(responseValues[0].value);
}
 
M

M B HONG 20

Martin - your continued help is greatly appreciated.

I have made some changes to my Web Service and client form to follow
your examples, but I'm afraid i am still getting "undefined" for the
values. My web service looks exactly like this, and is located in the
RemoteScripting folder inside of the wwwroot folder.

namespace RemoteScripting
{
[WebService(
Namespace="http://localhost/RemoteScripting/Service1",
Name="HelloWebService",
Description="This says hello/goodbye")]
//[SoapRpcService]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
InitializeComponent();
}

#region Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

[WebMethod]
public string SayHello(String strMyName)
{
return "Hello " + strMyName;
}

[WebMethod]
public bool SayGoodBye()
{
return false;
}
}
}

upon compile, the line "[SoapRpcService]" hits me back with an error,
saying "Namespace SoapRpcService could not be found".

and my client scriptblock looks like this:

<body onload="init();" MS_POSITIONING="GridLayout">
<SCRIPT language="JavaScript">
var soapCall = new SOAPCall();
soapCall.transportURI =
"http://localhost/RemoteScripting/Service1.asmx";
soapCall.actionURI =
"http://localhost/RemoteScripting/Service1/SayGoodBye";
soapCall.encode(0, "SayGoodBye",
"http://localhost/RemoteScripting/Service1", 0, null, 0, null);
var result = soapCall.invoke();
document.Form1.elements["TextBox2"].value = result.value;
document.Form1.elements["TextBox1"].value =
result.fault.faultString;


the result.fault.faultString is null, so I'm guessing there are no
errors with the call. However, the value is still "undefined", when it
should be "false". Do you see anything that is overtly wrong? thanks
again.

Charles.
 
M

Martin Honnen

M B HONG 20 wrote:

upon compile, the line "[SoapRpcService]" hits me back with an error,
saying "Namespace SoapRpcService could not be found".

It is in the .NET namespace
System.Web.Services.Protocols
so you need
using System.Web.Services.Protocols;
in your C# code.

var soapCall = new SOAPCall();
soapCall.transportURI =
"http://localhost/RemoteScripting/Service1.asmx";
soapCall.actionURI =
"http://localhost/RemoteScripting/Service1/SayGoodBye";
soapCall.encode(0, "SayGoodBye",
"http://localhost/RemoteScripting/Service1", 0, null, 0, null);
var result = soapCall.invoke();
document.Form1.elements["TextBox2"].value = result.value;

Where did you get the idea that there is a single value property? There
is none, I have already outlined what you need to do:
var responseValues = result.getParameters(false, {});
var firstValue = responseValues[0].value;
 
M

M B HONG 20

That did the trick. Thank you Martin, your continued help is greatly
appreciated.

Charles.
 

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

Members online

Forum statistics

Threads
473,815
Messages
2,569,702
Members
45,492
Latest member
juliuscaesar

Latest Threads

Top