views:

159

answers:

2

I have a WCF service which I am able to connect to from my web application and get data.

I now added a web reference to this wcf project to a wsdl file that a shipping company provides. Intention is to get shipping quotes..

I am able to access the objects that are generated from this wsdl file but when I call service.Authenticate("DEMO");

method almost nothing happens. I debug and see the debugger continue to the next lines but there is no change on service parameters and service.isauthorized is null..

Can you lead me to how I should debug this further and things I should check, or if there are additional steps that I need to ensure to have a web reference working on wcf app

Thanks

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

    }
}
A: 

Assuming the 'isauthorized' property is part of the proxy class on which you invoke the service; properties indicate state, which isn't really part of the services model for WCF service client proxies. Based on the results of the '.authorize()' method, your response class should tell you what you need to know regarding user authorization and you should manage the 'isauthorized' state yourself, likely through an application layer class that wraps the WCF proxy.

To determine if the service is being invoked, you could enable WCF tracing in the web.config or install a network trace application such as Netmon or Wireshark. For WCF tracing, you should run the Service Configuration Editor that comes with the Windows SDK (SvcConfigEditor.exe).

For the network tracing route, run the network trace application, set a capture filter to show only packets to/from the WCF physical host IP address, and watch for network traffic between the web client server and WCF server.

ChrisF
A: 

I do not know the internals of your freight_service object, but a WCF service don't have properties.

A [ServiceContract] can only expose methods. Typical WCF authentication scenario will raise an exception if you could not authenticate, or if you are using a sessionful service, you need another method like IsAuthorized() that will return a boolean that the session is storing.

Pierre-Alain Vigeant