100分求WCF+silverlight发布问题,自己没发布过,理论派的不要回复

lcp147572931 2011-04-21 02:29:23
我建的silverlight项目。
SL和宿主SL.Web

SL.web下建了个WCF应用程序 然后用SL调用这个WCF 本地运行一切正常 但是发布到2003操作系统的服务器II上 就取不到数据了 关于SL项目下的 ServiceReferences.ClientConfig 到底怎么配置
难道你们把address里面写上固定IP 可是生成的话 就在XAP包内了 换个地方部署 又不行 所以想问一下你们发布用WCF+SL的人 是怎么发布的
...全文
295 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ning823 2011-04-22
  • 打赏
  • 举报
回复
其实你的2个问题我都碰到过,你怎么就看不懂我给的答案呢
ning823 2011-04-22
  • 打赏
  • 举报
回复
http://www.aspxcs.net/HTML/2345222075.html
lighting_pig 2011-04-22
  • 打赏
  • 举报
回复
web.config代码如下

<bindings>
<basicHttpBinding>
<binding name="wcfbasicHttpBinding" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>


<behaviors>

<serviceBehaviors>
<behavior name="behaviorDefault">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>

<services>
<service behaviorConfiguration="behaviorDefault" name="PMIS.wcf.MesWcf">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="wcfbasicHttpBinding"
contract="PMIS.wcf.MesWcf" />
</service>
</services>

--------
web.config好像不重要,如果你通过wcf只是传递小数据的话,web.config就算不配好像也能跑
如果需要传递大数据,web.config你可以参考我的
lighting_pig 2011-04-22
  • 打赏
  • 举报
回复
这个问题好解决,我说说我怎么做的给你参考一下吧

------
web页面代码

private string getRootPath()
{
string str = "http://" + this.Request.Url.Authority + Request.ApplicationPath;

if (str[str.Length - 1] != '/')
{
str += "/";
}
return str;
}

//这个xap调用了3个不同的wcf
private string getInitParamsString()
{
string PopedomWcf = getRootPath() + "wcf/PopedomWcf.svc";
string OrganizationWcf = getRootPath() + "wcf/OrganizationWcf.svc";
string MesWcf = getRootPath() + "wcf/MesWcf.svc";

string strResult = "PopedomWcf=" + PopedomWcf;
strResult += ",OrganizationWcf=" + OrganizationWcf;
strResult += ",MesWcf=" + MesWcf;

return strResult;

}

public string InitParams
{
get
{
return getInitParamsString();
}
}

aspx代码如下:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%" >
<param name="source" value="../ClientBin/slMes.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<param name="InitParams" value="<% =InitParams %>" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object>

silverlight程序app.xaml代码如下:

public static IDictionary<string, string> Params;

private void Application_Startup(object sender, StartupEventArgs e)
{
Params = e.InitParams;

this.RootVisual = rootVisual;
}

public static MesWcfClient GetMesWcfClient(string url)
{

EndpointAddress address = new EndpointAddress(url);

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);

binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
binding.Name = "wcfbasicHttpBinding";

return new MesWcfClient(binding, address);
}

public static MesWcfClient GetMesWcfClient()
{
string url = App.Params["MesWcf"];

return WcfHelper.GetMesWcfClient(url);
}

调用wcf的代码如下

MesWcfClient client = App.GetMesWcfClient();
client.work();

//****************************************
总的思路是web页面传递wcf的url给silverlight程序,silverlight程序在Application_Startup里获取到这个url,然后写一个函数通过这个url获取wcf代理类,最后,所有需要调用wcf的地方都用这个自定义的入口调用wcf!
用这个方法做需要注意一点的是SL项目下的 ServiceReferences.ClientConfig最好删掉,这样开发的时候如果某个地方不是通过url获取wcf代理类而是用默认的方法获取,开发的时候就会直接报错。
lcp147572931 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 madaming 的回复:]

http://blog.csdn.net/madaming/archive/2011/04/17/6329640.aspx
[/Quote]

这个我看过了 不行呀
lcp147572931 2011-04-21
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20110419/09/3efc9cba-f62a-45fa-a0c0-2f729b0aeba0.html?33111
这边我还有个帖子啊 谁解决了 190分 都给他啊
lcp147572931 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 swt839 的回复:]

我是固定的ip,换地方再重新生成咯
[/Quote]
重新生成 要是只拷贝 机器上没VS呢
swt839 2011-04-21
  • 打赏
  • 举报
回复
我是固定的ip,换地方再重新生成咯

8,735

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧