繁体   English   中英

在同一解决方案中引用(调用)Web服务

[英]Referencing (Calling) Web Service within same solution

在此处输入图片说明 我创建了两个单独的项目,一个是Web窗体,一个是Silverlight。 我已经在Web项目中实现了Web服务,该服务通过Silverlight的ServiceReference进行调用,以将一些值传递回Web项目。

问题:在测试中,如果我在一个VS实例中启动我的Web项目,而在另一个VS实例中启动Silverlight Project,则它可以100%起作用-Silverlights调用了该服务,而我在Web Project中收到了调用,等等。

我现在已经将Silverlight项目与Web项目包含在相同的解决方案中,但现在不起作用-没有错误,没有来自服务的答复,没有任何...

我的ServiceReferences.ClientConfig的内容:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="EnrollServiceSoap" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8080/EnrollService.asmx"
            binding="basicHttpBinding" bindingConfiguration="EnrollServiceSoap"
            contract="EnrollServiceReference.EnrollServiceSoap"
            name="EnrollServiceSoap" />
    </client>
</system.serviceModel>

我在Web项目中的服务实现:

namespace XXX
{
/// <summary>
/// Summary description for EnrollService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class EnrollService : System.Web.Services.WebService
{

    [WebMethod]
    public void UpdateFingerTemplates(string PersonID)
    {
        Person person = SQLData.Persons.getPersonByID(PersonID);
        Person newPerson = SQLData.Persons.getPersonByID(PersonID);
        newPerson.ID_Number = PersonID;

        SQLData.Persons.UpdatePerson(newPerson, person, null);

    }
}
}

将服务项目映射到本地IIS进行调试。 并从IIS路径添加服务引用,它应该可以在一个解决方案中正常工作。.右键单击WCF项目>>属性>> Web >>选择本地IIS Web服务器>>输入IIS应用程序路径的项目URL。

解决了问题...我是一个Dumb @ ss,通过从BackgroundWorker.ReportProgress调用WCF服务(我没想到会是一个问题(如果有人在乎为什么),却被忽略了,在帖子中提到)。调用WCF服务到BackgroundWorker.ProcessCompleted解决了该问题。

在您的Silver Light项目中,先删除旧的服务参考,然后再选择“项目”菜单===>添加服务参考====>高级... ====>添加Web参考

然后在此解决方案链接中选择Web服务。

暂无
暂无

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

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