基于WCF的Web参考问题

基于WCF的Web参考问题,wcf,web-services,wsdl,Wcf,Web Services,Wsdl,我有一个WCF服务,我可以从我的web应用程序连接到该服务并获取数据 现在,我将对这个wcf项目的web引用添加到一个航运公司提供的wsdl文件中。目的是获取装运报价 我能够访问从这个wsdl文件生成的对象,但是当我调用service.Authenticate(“DEMO”) 方法几乎什么也没发生。我调试并看到调试器继续到下一行,但服务参数没有更改,service.isauthorized为null 你能告诉我应该如何进一步调试这个,以及我应该检查的事情,或者我是否需要额外的步骤来确保在wcf应

我有一个WCF服务,我可以从我的web应用程序连接到该服务并获取数据

现在,我将对这个wcf项目的web引用添加到一个航运公司提供的wsdl文件中。目的是获取装运报价

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

方法几乎什么也没发生。我调试并看到调试器继续到下一行,但服务参数没有更改,service.isauthorized为null

你能告诉我应该如何进一步调试这个,以及我应该检查的事情,或者我是否需要额外的步骤来确保在wcf应用程序上有一个web引用

谢谢

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();
        }    

    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Runtime.Serialization;
使用System.ServiceModel;
使用系统文本;
使用ShippingCalculator.com.freight.api;
名称空间ShippingCalculator
{        
公共类ShippingService:IShippingService
{
货运服务=新货运服务();
公共字符串GetData(int值)
{
service.setConnectionType(“.net”);
服务。验证(“演示”);
OriginRequest origin=新的OriginRequest();
origin.zip=“60101”;
DestinationRequest destination=新DestinationRequest();
destination.zip=“10001”;
PackageRequest package=新PackageRequest();
package.weight=“10”;
ShipmentInfoRequest shipmentInfo=新的ShipmentInfoRequest();
shipmentInfo.ship_date=DateTime.Now.AddDays(5);
服务。设置原点(原点);
service.setDestination(目的地);
服务包(包);
服务.设置shipmentInfo(shipmentInfo);
Quote=service.getQuote();
返回string.Format(“引号编号:{0}
”,引号.QuoteNumber); } } } 使用制度; 使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.Mvc; 使用ShippingTestApp.ShippingServiceReference; 命名空间ShippingTestApp.Controllers { [手机错误] 公共类HomeController:控制器 { 公共行动结果索引() { ShippingServiceClient ShippClient=新的ShippingServiceClient(); shipClient.GetData(0); ViewData[“Message”]=shipClient.GetData(0); 返回视图(); } } }
假设“isauthorized”属性是调用服务的代理类的一部分;属性表示状态,它实际上不是WCF服务客户端代理的服务模型的一部分。根据“.authorize()”方法的结果,您的响应类应该告诉您需要了解的有关用户授权的信息,您应该自己管理“isauthorized”状态,可能是通过包装WCF代理的应用程序层类

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


对于网络跟踪路由,请运行网络跟踪应用程序,设置捕获筛选器以仅显示进出WCF物理主机IP地址的数据包,并监视web客户端服务器和WCF服务器之间的网络流量。

我不知道您的
货运服务对象的内部结构,但是WCF服务没有属性


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

发货人对象是服务还是服务返回的数据?您是否能够发布源代码片段?对不起,我应该更具体一些,您可以发布用于使用此wcf服务的代码吗?此服务作为服务引用添加到应用程序中