Geert van Horrik

Hi all,

I am developing a Web Service inside a Windows Service via the soap.tcp protocol. This all works, and I have created the webservice at soap.tcp://myservice.mycompany.com:8083/MyService.

When I add a Web Reference to a test project (local computer), it automatically sets the URL to soap.tcp://localhost:8083/MyService. All works great with this.

However, when I set the Url to soap.tcp://myservice.mycompany.com:8083/MyService on my local machine, I get an exception that the computer actively refused the connection.

When I run netstat -a, it says that mycomputer:8083 is listening. I have already disabled the Windows Firewall. I am able to ping myservice.mycompany.com (which leads to my computer).

Do you have any idea what can be wrong with my configuration

Best regards,




Re: ASMX Web Services and XML Serialization Server actively refused connection

timvw

- Check if the server overthere is configured to allow incoming connections on port 8083.
- Check if you can connect to myservice.mycompany.com 8083






Re: ASMX Web Services and XML Serialization Server actively refused connection

Geert van Horrik

Hello Tim,

Thank you for your answer.

Can you please tell me how I can check if my "server" (which is actually just me development PC) When I run netstat, it says it is listening. Are there other ways to check if my server allows incoming connection

Which tool should I use to connect Remember that I use soap.tcp protocol to host my server, so I cannot simply connect to this in my browser or via telnet.

I normally generated the client class using:

wsewsdl3.exe soap.tcp://localhost:8083/MyService /out:CommandListenerProxy.cs /type:webClient /language:CS

Now I changed it to:

wsewsdl3.exe soap.tcp://myservice.mycompany.com:8083/MyService /out:CommandListenerProxy.cs /type:webClient /language:CS

And the tool is unable to create the class, so it must have something to do with not allowing incoming connections (but how can I enable this)

Best regards,






Re: ASMX Web Services and XML Serialization Server actively refused connection

timvw

I've got good and bad news Wink

- I can reproduce the problem, and it's not a computer configuration (firewall, network, ... ) issue...
- The problem is that the tcp.soap binding seems to need some configuration which i haven't figured out to get it right yet (been playing with Address and Via uris and SoapActor attribute but haven't found a solution)





Re: ASMX Web Services and XML Serialization Server actively refused connection

Geert van Horrik

Hi Tim,

I thought you had some good news too Wink (both are bad: now I don't get a brand new development PC and it also doesn't work yet).

No, just kidding, thanks for trying to help me out on this one!

It's strange that the examples of WSE (see the WSE 3.0 installation folder, {Program Files}\Microsoft WSE\v3.0\Samples\CS\QuickStart\Hosting\ConsoleService) are not working either when connection "from the outside" (localhost, but via my official IP instead of localhost).

Best regards,






Re: ASMX Web Services and XML Serialization Server actively refused connection

Geert van Horrik

Just a quick update when I was reading http://msdn2.microsoft.com/en-us/library/microsoft.web.services3.addressing.endpointreference.aspx:

Note:
If you build a cross-domain Web service, you must register the SoapReceiver using the full domain name of the EndpointReference . Otherwise, the Web service will not be accessible outside the domain that the Web service was created in.

Can this be the problem
Best regards,





Re: ASMX Web Services and XML Serialization Server actively refused connection

Geert van Horrik

I just keep updating:

Registering a TCP soapreceiver is simply adding the EndpointReference to the SoapReceivers class (via the Add method).

I just tested this:

Uri address = new Uri("soap.tcp://" + System.Net.Dns.GetHostName() + ":8083/MyService");

The hostname result is pc2126, the the complete url is: soap.tcp://pc2126:8083/MyService.

When I use this connection string in the client too, it seems to work. Pinging pc2126 gives me the same IP as myservice.mycompany.com, so it's weird that one DNS name is working, and the other is not...






Re: ASMX Web Services and XML Serialization Server actively refused connection

Geert van Horrik

I found the problem!

On server side:

/// <summary>

/// Initializes the soap service listener

/// </summary>

private void InitializeServiceListener()

{

try

{

// Create address

string address = string.Format("soap.tcp://{0}:{1}/{2}",

Dns.GetHostAddresses(Dns.GetHostName())[0],

Settings.Default.ServicePort, Settings.Default.ServiceName);

// Create SOAP listener & endpoint

Uri addressUri = new Uri(address);

// Start hosting the web service

SoapReceivers.Add(new EndpointReference(addressUri), typeof(CommandListener));

// Log

EventLogHelper.EventLog.WriteEntry(address, EventLogEntryType.Information);

}

catch (Exception ex)

{

// Log

EventLogHelper.EventLog.WriteEntry(string.Format(Resources.ErrorInitializingWebservice, ex.Message),

EventLogEntryType.Error);

}

}

On client side:

// Set up server

MyService server = new MyService ();

server.Url = string.Format("soap.tcp://{0}:{1}/MyService",

Dns.GetHostEntry("myservice.mycompany.com").AddressList[0], Settings.Default.ServicePort);

or

// Set up server

MyService server = new MyService ();

server.Url = string.Format("soap.tcp://{0}:{1}/MyService",

Dns.GetHostEntry("192.168.1.156").AddressList[0], Settings.Default.ServicePort);

It's stupid that directly using the IP or DNS record isn't working.

Now you can use any IP (as long as you have access to it etc).

Thanks for all your help and this MUST be a great resources for everyone since there are a lot of people with the same problem who do not know how to solve it!

Best regards,






Re: ASMX Web Services and XML Serialization Server actively refused connection

timvw

I've found a way so that allows you to use wsewsdl3.exe soap.tcp://myservice.mycompany.com:9090/MyService to generate the proxy Smile)) In essence, it will create a binding on the first ip address that is found for the hostname (via uri).. and handle requests for the hostname (address).



static void Main(string[] args)
{
EndpointReference epr = GetEndpointReference("myservice.mycompany.com", 9090, "MyService");
SoapReceivers.Add(epr, typeof(MyService));

Console.Write("{0}Press any key to continue...", Environment.NewLine);
Console.ReadKey();

SoapReceivers.Remove(epr);
}

static EndpointReference GetEndpointReference(string host, int port, string path)
{
Uri address = new Uri(string.Format("soap.tcp://{0}:{1}/{2}", host, port, path));
Uri via = new Uri(string.Format("soap.tcp://{0}:{1}/{2}", Dns.GetHostEntry(host).AddressList[0], port, path));
return new EndpointReference(address, via);
}