WebService getting the local address instead of ip address - silverlight

I trying to run a silverlight app. I have a server with a knowed ip, and I am trying to install the sl app in this server.
The problem is, if I access the service using the ip like: http://serverip:port/Service.svc, the service runs with no problem, but, service shows this:
svcutil.exe http://serverLocalAddress:port/Service.svc?wsdl
So, when I run the app from the local domain, I have no problem, but, when I run from outside domain (from my house for example), the app doesn't run correctly, showing a error in the service.
I have configured my ServiceReference.ClientConfig endpoint address with: "http://serverip:port/Service.svc".
There are other place to change to fix this problem?
Regards.
Eduardo.

You may want to be explicit about your address in your code versus in your ClientConfig. This can give your more control over your url, you can event move it to your Application InitParams.
To do this, modify your service declaration to include the address and change this
_proxy = new WCFServiceClient();
to
_proxy = new WCFServiceClient("BasicHttpBinding_IWCFService", "http://serverip:port/Service.svc");
I don't recommend hard coding the address as I've done here, but this should get you started.

Related

Any way to use URL Fetch Service in .NET Core?

Just ran into an issue where I have a service in Google App Engine Flex (GAEF) attempting to perform a GET operation on another service in GAEF (within the same Project) only to get a 403. After hours of guessing, I just added the caller's VM IP Address in the firewall rule to Allow and everything worked. I later read that URL Fetch service uses a set pool of static ip addresses which I could use reliably instead of having to constantly update the firewall rules whenever the caller has a new ip address.
Unfortunately, I don't see anywhere on how I can use this on .net core. Anybody run into this before?

angularjs URLs not resolving correctly on client that is running on second machine on local network

Developed client on one machine, now trying to get it to run on another in the local network (I access the client using a URL containing an IP address rather than a hostname). The client on the new machine does not seem to recognize that it needs to use the IP to formulate URLs.
I solved this by upgrading to angularjs 1.7.7.

location of $http.get('xxx/xxx/xxx', parameter)

I'm new to angularjs. I'm working on a angularjs project which was started by other ppl. In the code, some functions are defined as the format $http('url', parameters). The urls are something like 'abc/def/hijk'. I want to modify the functions but I cannot find the location of the urls. where can I find the source files given the links? thanks.
Is this more of an environment/domain question?
$http is just an angular core service for make http requests.
When you say
I want to modify the functions but I cannot find the location of the urls. where can I find the source files given the links?
That is a very open ended question. If for example my angular site is hosted at http://mysite.local and the links looks like $http.get('/someUrl', config), then I would visit http://mysite.local/someUrl to see what is there. If it is in fact connecting to the same domain then ping it.
ping mysite.local
Whatever IP address you get back you may be able to resolve the hostname
ping -a 192.168.0.80
If this was a windows machine you could rdc and check the iis instance, otherwise ssh and check whats hosting on port 80?
Essentially what I'm getting at is... we don't no where your predecessor may have stored source or what your environment is setup like but with some investigation you may be able to shed some light.

GAE urlfetch Host header set to IP address instead of hostname

I am calling a third party web service from app engine. This particular service is picky. I ran into an issue where calls would work fine for a while, then stop working, then start working again. I realized that if I manually stopped all instances in the admin console, that the calls would work again.
I setup a proxy to route the calls through that so I could see the headers and all detail. I think I have tracked the issue down to the following. After an instance has been up for a while (the app usually just needs 1 to 3 instances right now) app engine will start using the IP address of the destination as the value for the host header instead of the hostname. Well the service doesn't like that. Whether it should care is another matter.
So my question is, why does app engine use the ip address for the host header eventually instead of the hostname? And, of course, is there anything I can do about it? I know that I cannot set the host header, but maybe there is something else that can be done.
Thanks for any insight.
First, thank you for finding this behavior. We have had intermittent issues with urlfetch for a long time, and will try to detect if this is the issue.
One thing you could try is to target a specific instance/module:
http://instance.version.module.app-id.appspot.com
and cycle through the instances. If you just target the module, it will kill the instance after some inactivity. So, perhaps that would not trigger the GAE DNS shortcut.
Another trick would be to add a fake, random, query string after your url: ?foo=D7hfka67h. Perhaps that would prevent GAE from recognizing the repeat url, and trying to shortcut the DNS.

Deployed silverlight enabled WCF Service Stops Working when development server is stopped

I have a silverlight business aplication that gets data from silverlight enabled webservice.
When I run the application in dev environment, it works fine.
when i deploy the application and the Asp.net web development server is working, then to the application works fine.
But when I stop the development server, the application can't access a service.
My questions are:
When I deploy a silverlight business application, doesn't the service get deployed and get started.
The endpoint address in my ServiceReferences.Clientconfig file is endpoint address="http://localhost:9702/MyWebservice.scv. Do I need to change this?
The enpoint address in the web.config is blank.
Appreciate your help
Because the WCF client code is declared as a "partial" class, what I've been doing to this point is creating another c# partial class file to host a GetClient() method on it. You'll notice that the code is taking into account the port that the service is on... in a few of the environments that I've posted or will be posting to, as well as the development environment, the application is not always on port 80.
Namespace Project.Service
{
public partial class ServiceClient
{
public static ServiceClient GetClient()
{
return new ServiceClient("CustomBinding_Service",
new System.ServiceModel.EndpointAddress(new Uri(string.Format("{0}://{1}:{2}/Services/Service.svc",
Application.Current.Host.Source.Scheme, Application.Current.Host.Source.Host, Application.Current.Host.Source.Port), UriKind.Absolute)));
}
}
}
Hope this helps someone!
Yes you are going to want to change your endpoint address. I recommend doing it in the silverlight code when creating the connection to the WCF service. The service itself lives on the web server, whereas the silverlight application lives on the clients computer. If the web server stops, the web service stops but the silverlight app can keep running.
edit:
To do this in code, as long as the path is always in the same domain as the app you can use do like so:
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None) //Use whatever security you need here
{
MaxReceivedMessageSize = int.MaxValue,
MaxBufferSize = int.MaxValue
};
Client client = new Client(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../MyService.svc")));
Thanks so much for your help. I tried your approach to create the client code but that didn't work. And that's because the problem seems to be somewhere else.
So I installed fiddler to see the traffic.
Fiddler showed that the service was being accessed but the http response code was 302 showing that there was some redirection involved.
The address of my application is like this http:///Silverlightapp/(S(oirppxrwzhlf2a2vbia1ui45))/Default.aspx#/Home and it is hosted on IIS 6.
So I had to employ a workaround by installing the service on machine with IIS7 (and there was no session id involved like in the above url).I still kept the silverlight application hosted on IIS 6.
Anyway, in summary, to anyone who reads the thread, I did the following to troubleshoot and solve issue(temporarily)
Changed the end point address in the ServiceReferences.ClientConfig file. When you add the service using discover option in VS, the endpoint address is of the localhost and this must be changed.
Registered the service model using ServiceModelReg -i command. (this solved my problem that my applicaiton was only working from development server and not IIS)
-Put the CrossDomain and ClientAccessPolicy files in c:]inetpub\wwwroot folders.
-Used fiddler to look at http response codes. I had to do no configuration in fiddler.
Changed the binarymessageEncoding to textMessageEncoding iin the web.config file of the silverlight web project that also hosted the ecf service. I did this becasue adding a silverlight enabled wcf service creates a custom binding configuration in the web.config file by default uses binary encoding. I needed text encoding to see errors in fidder. But this didn't help much becasue I only saw the name of the operation in the Inspector>xml tab in fiddler. This was the same even after my issues was resolved by workaround.
Thanks for the help
Don't do it in code. Otherwise you won't be able to change it later without recompiling the application (when the address will need to change, perhaps years down the road when you've lost the source code :)
Change the address in ServiceReferences.ClientConfig to where the service is actually hosted... e.g. http://example.com/myVdir/MyWebservice.svc
If later on you need to change the address without recompiling:
- Open the .xap file (it's just a zip file with a different extension)
- Find the .ClientConfig file and change the address
- Put it back together as a .zip file and rename to .xap
Also, I can't remember anymore whether the .ClientConfig supports relative addresses (e.g. just "MyWebService.svc"), but if it does it may be a good solution as well.

Resources