WCF service called from compact framework - wcf

I have been trying to follow this article on communicating with a WCF service from a mobile device (using compact framework 3.5). I have the service running on the desktop, and it tells me that it's running as:
http://localhost:1414/MyService.svc
I can see this in my client, but when I try to access it, I get this error:
There was no endpoint listening at http://localhost:1414/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
So I did:
InnerException: {"No connection could be made because the target machine actively refused it"}
I am running from the emulator, which the article states did not work - I therefore suspect that I have encountered the same issue. So my question is, does anyone know why this issue may occur?
EDIT:
Just to clarify, this works fine when deployed to the device. It's just the emulator that has the problem.
EDIT:
Thanks to #Shiraz Bhaiji I have made some progress with this now, but am now getting the error returned:
CFFaultException
This seems to be the only error information I can get, and it's caused by the call:
MyServiceServiceClient client = new MyServiceServiceClient(binding, endpoint);
returnString = client.MyFunc1();
I have changed the endpoint to reference my I.P. address directly as follows (the WCF service is running on my PC at the minute):
Binding binding = MyServiceServiceClient.CreateDefaultBinding();
string remoteAddress = MyServiceServiceClient.EndpointAddress.Uri.ToString();
EndpointAddress endpoint = new EndpointAddress("http://1.1.1.1/MyService/MyService.svc");

Check Eric Schneider's answer on this link: http://social.msdn.microsoft.com/Forums/en/netfxcompact/thread/b5be4c83-40ca-423b-9068-8614779fed5f
Connect to the server using the IP address.

Try changing localhost to the actual name of your computer.

Related

Silverlight Security Issue Help - Debugging resource strings are unavailable.

I hosted silverlight application iis and that can be accessed in multiple ways..
When I access using Qualified name of server IP address IT WORKS fine:
http://[QUALIFIEDNAME]/WebUAT/App.aspx
When I access using IP address like below:
http://[IPADDRESS]/WebUAT/App.aspx
It gives error below:
[Async_ExceptionOccurred]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.20913.00&File=System.dll&Key=Async_ExceptionOccurred StackTrace : at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
Follow these,
(i) Try to use fiddler and find the request which is making crossdomainpolicy xml request.
(ii)Check whether it is failing, if so add the crossdomain and clientaccesspolicy to the root folder of your Application
(iii)Check whether the service which is invoked by your application is blocked by firewall.

Error when update a content in ektron

I have an ektron8.7 application in which I'm trying to update a content. (I'm trying to make a content deleted by setting its ExpireDate)
Dim contentItem As ContentData = contentApi.GetItem(contentId)
contentItem.ExpireDate = DateTime.Now.AddDays(-1)
contentApi.Update(contentItem)
I am getting the following exception here
http://MyPC:8732/Ektron.ASM.EktronServices/CmsHelperService2.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details
and the InnerException is,
"No connection could be made because the target machine actively refused it MyIP:8732"
My website was upgraded from ektron 8.0 to 8.7
How can I resolve this error?
Make sure that your EktronWindowsService40 is running on your machine; that port 8732 indicates that the server is trying to send data to the service (which handles go live and expiration dates). If that is not running it won't be able to complete your request.
If it is running, make sure that the name 'MyPC' resolves to the address of the machine running the site.
If all else fails, check your Event Viewer, under 'Applications and Services log' - there is an event log called 'EktronL4' which is used by the Ektron Windows Service to log errors. If there are any entries besides 'Service Initialized Successfully', and 'Service Started Successfully' after starting the service, there is a problem with the service itself. At that point, call Ektron Support.

Web service throws ORA-12505 when invoked from a device, but not otherwise

I have a web service running on a client's server. When I access it through remote desktop on the server and type in the parameters, it works. When I access it from my computer and type in the parameters, it works. When I access it from my application on a handheld device connected to my computer, the web method throws
{System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException:
Server was unable to process request. ---> System.Data.OracleClient.OracleException:
ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
The device is not connecting to the database, it just invokes the web service and passes parameters to it. I also created a test method that just returns the parameters to the device without connecting to the DB, and the parameters passed are fine.
This is driving me crazy, I have no idea how this is possible. Anyone got any ideas?
Edit: Work internet died and made the problem obvious. The problem is actually that my local dev version of the service is getting invoked from the device. I have no idea why. This is the code of the service constructor (derived from SoapHttpClientProtocol):
public Service1() {
this.Url = "LOCAL (WRONG) URL";
}
By executing this code:
server.Service1 s1 = new server.Service1();
s1.Url = "CLIENT (CORRECT) URL";
string test = s1.TestMethod(parameters);
After the first line, s1.Url is, of course, the wrong url. After the second line, s1.Url is the correct url. The third line however, connects to the wrong, development service! I only noticed this because my internet died and a connection to client's server should have failed, yet it kept working... Trying to figure out why this is happening.

can't enable net.tcp port sharing

I'm doing my dev work on a Window 7 x64 machine, deploying to a Windows 2008 x32 server. At the moment I'm adding WCF services to some internal apps so that we can build smaller clients using net.tcp bindings that report to the user what the server is doing without running multiple instances of the server. To cut back on how much administration the apps will require, I tried enabling port sharing on my first server app. I'm using the app to self-host the WCF service so they can be easily moved from one server to another if necessary. Here's the code starting the server:
Dim _service_host As ServiceHost
Dim active_server_address As Uri = New UriBuilder("net.tcp", "localhost", CInt(My.Settings.ServerPort)).Uri
_service_host = New ServiceHost(GetType(UpdateServiceOps), active_server_address)
_service_host.AddServiceEndpoint(GetType(IUpdateService), New NetTcpBinding With {.Name = "endpoint_tcp"}, "MiddlewareEndpoint")
_service_host.Description.Behaviors.Add(New ServiceMetadataBehavior)
_service_host.AddServiceEndpoint(GetType(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding, "mex")
_service_host.Open()
That works great. When I change it to what's below, however, I get an error. Here's the code:
Dim _service_host As ServiceHost
Dim active_server_address As Uri = New UriBuilder("net.tcp", "localhost", CInt(My.Settings.ServerPort)).Uri
_service_host = New ServiceHost(GetType(UpdateServiceOps), active_server_address)
_service_host.AddServiceEndpoint(GetType(IUpdateService), New NetTcpBinding With {.Name = "endpoint_tcp", .PortSharingEnabled = True}, "MiddlewareEndpoint")
_service_host.Description.Behaviors.Add(New ServiceMetadataBehavior)
_service_host.AddServiceEndpoint(GetType(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding, "mex")
_service_host.Open()
I get the following error when I put a breakpoint at the last line: Unable to automatically step into the server. Connecting to the server machine 'nettcpportsharing' failed. The requested name is valid, but no data of the requested type was found. The Try...Catch block housing that code says the exception type is AddressAlreadyInUseException...but when I run netstat I don't see anything else listening on that address. There's no occurrence of 'nettcpportsharing' anywhere in my solution. I've checked to make sure that the Net.Tcp Port Sharing service is started. Any ideas?
I think this may be a permissions issue. Please see the associated article which explains how to configure the port sharing service to support self-hosted services.
(For production purposes I would strongly recommend using IIS Hosting with WAS anyway - it makes management of the services much cleaner and you get dynamic startup/shutdown for free.)

Silverlight WCF service acting strange

I have a silverlight project that calls into a wcf service. Everything works fine on my local machine.
However when I deploy to a virtual machine, with the exact same query the wcf service returns, but the result is empty.
I've tried debugging, but have not been able to get it to break in the wcf service.
Any ideas what the problem could be, or how I could go about debugging it?
Thanks
I figured out what the problem is, but am not sure what the solution is.
In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightApiService.svc
I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:
http:///.../SilverlightApiService.svc
So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.
I had this exact problem when deploying to amazon ec2 - The machine name for the service was being returned in the wsdl rather than the dns.
There were a couple solutions (one involved creating static wsdl - yuck!)
But the other was creating a sort of factory pattern for the service
This thread (you can read it all, but the answers are at the bottom.)
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c7fd51a2-773e-41d4-95a0-244e925597fe/
The slight downfall with this is that although it works - if you change the location of the server, you will need to remember to update your config - Which although isn't hard, it's easy to forget to do.
Can you give us a bit more information? What kind of binding are you using? What does the service config and the client config look like? Where do you get your data from that gets returned? Could it be the service on the VM just doesn't get any data? (e.g. queries a database that just doesn't have the data requested?)
Marc
I have had that happen before. I would try this. Set you start page as the web service file and run the app. Then set the start page back to your default page. Then update all the server references in your SL project. Recompile everything and republish. This has helped me a bunch of times in the past.
I figured it out.
Basically my machine name was hard coded in my ServiceReferences.ClientConfig file in my silverlight project.
What I had to do was specify programmatically what url to use for the service reference when instantiating my service client:
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri
(Application.Current.Host.Source, "../WebServices/SilverlightService.svc"));
ServiceClient serviceClient = new ServiceClient("BasicHttpBinding_IService", address);
I figured out what the problem is, but am not sure what the solution is.
In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightService.svc
I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:
http:///.../SilverlightService.svc
So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.