2009-08-27 15 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(),它將返回會話正在存儲的布爾值。