2009-08-27 18 views
0

我有一个WCF服务,我可以从我的Web应用程序连接到并获取数据。WCF上的Web引用问题

我现在添加了一个web引用这个wcf项目到一个航运公司提供的wsdl文件。意图是得到航运报价..

我能够访问从此wsdl文件生成的对象,但是当我调用service.Authenticate(“DEMO”);

方法几乎没有任何反应。我调试并看到调试器继续到下一行但服务参数和服务没有变化。授权为空..

你能带我到我应该如何进一步调试,我应该检查,或者如果还有,我需要确保有一个Web引用工作WCF应用

感谢

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.Text; 
using ShippingCalculator.com.freight.api; 

namespace ShippingCalculator 
{   
    public class ShippingService : IShippingService 
    { 
     freight_service service = new freight_service(); 


     public string GetData(int value) 
     { 
      service.setConnectionType(".net"); 
      service.Authenticate("DEMO"); 

      OriginRequest origin = new OriginRequest(); 
      origin.zip = "60101"; 

      DestinationRequest destination = new DestinationRequest(); 
      destination.zip = "10001"; 

      PackageRequest package = new PackageRequest(); 
      package.weight = "10"; 

      ShipmentInfoRequest shipmentInfo = new ShipmentInfoRequest(); 
      shipmentInfo.ship_date = DateTime.Now.AddDays(5); 

      service.setOrigin(origin); 
      service.setDestination(destination); 
      service.setPackage(package); 
      service.setShipmentInfo(shipmentInfo); 

      Quote quote = service.getQuote(); 

      return string.Format("Quote Number: {0}<br /> ", quote.QuoteNumber); 
     } 

    } 
} 


using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using ShippingTestApp.ShippingServiceReference; 

namespace ShippingTestApp.Controllers 
{ 
    [HandleError] 
    public class HomeController : Controller 
    { 
     public ActionResult Index() 
     { 
      ShippingServiceClient shipClient = new ShippingServiceClient(); 
      shipClient.GetData(0); 

      ViewData["Message"] = shipClient.GetData(0); 

      return View(); 
     }  

    } 
} 
+0

托运人对象是服务还是服务返回的数据? – 2009-08-27 19:26:31

+0

其服务 – kaivalya 2009-08-27 19:27:34

+0

你能发布你的源代码片段吗? – 2009-08-27 19:29:32

回答

1

假设“isauthorized”属性是在其上调用服务代理类的部分额外的步骤;属性指示状态,这不是WCF服务客户端代理服务模型的真正组成部分。基于'.authorize()'方法的结果,你的响应类应该告诉你你需要知道关于用户授权的内容,你应该自己管理'isauthorized'状态,可能是通过包装WCF代理的应用层类。

要确定服务是否被调用,您可以在web.config中启用WCF跟踪或安装网络跟踪应用程序,如Netmon或Wireshark。对于WCF跟踪,您应该运行Windows SDK附带的服务配置编辑器(SvcConfigEditor.exe)。

对于网络跟踪路由,运行网络跟踪应用程序,设置捕获过滤器以仅显示WCF物理主机IP地址的数据包,并监视Web客户端服务器和WCF服务器之间的网络通信。

0

我不知道你的freight_service对象的内部,但一个WCF服务没有属性。

A [ServiceContract]只能公开方法。如果您无法进行身份验证,或者如果您使用会话服务,则典型的WCF身份验证方案将引发异常,您需要另一种方法,如IsAuthorized(),它将返回会话正在存储的布尔值。