简体   繁体   English

WebService获取本地地址而不是IP地址

[英]WebService getting the local address instead of ip address

I trying to run a silverlight app. 我试图运行Silverlight应用程序。 I have a server with a knowed ip, and I am trying to install the sl app in this server. 我有一台具有已知IP的服务器,并且我正在尝试在此服务器上安装sl应用程序。

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 问题是,如果我使用ip之类的服务访问服务: http:// serverip:port / Service.svc ,该服务运行就没有问题,但是服务显示如下: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". 我已经将ServiceReference.ClientConfig端点地址配置为:“ 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. 您可能希望在代码中或在ClientConfig中明确显示您的地址。 This can give your more control over your url, you can event move it to your Application InitParams. 这可以让您更好地控制URL,可以将其移动到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. 我不建议像在这里一样对地址进行硬编码,但这应该可以帮助您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM