WCF服务的问题。服务无法调用

时间:2015-09-15 09:17:19

标签: c# wcf

我正在创建一个WCF服务,但是当我调用我所做的服务时,我遇到了一些问题。以下是该服务的代码。

public void CreateTradeItemWithExtensions(string gtin, string targetMarketCountryCode, string effectiveDate, string publicationDate, string lastChangedDateTime, string tradeItemUnitDescriptor, string brandName, bool isTradeItemBaseUnit, string descriptionLanguage, string functionalName, string shortDecription, int gPC, string articleNumber, bool isTradeItemAConsumerUnit, bool isTradeItemADespatchUnit, bool isTradeItemAnOrderableUnit, bool isTradeItemAnInvoiceUnit, string startAvailability, bool isPackagingMarkedReturnable, string packagingTypeCode, bool isBarCodeOnPackageVariableMeasureBarCode, decimal netContent, decimal height, decimal grossWeight, decimal width, decimal depth, decimal netWeight, string isDangerousSubstance, string barCodeType, bool isPriceOnPack, string classComplianceRegulationCode, string consumerSafteyInformation, string doesTradeItemHaveAutoReaderTracker, bool isProductCustomizable, string isTradeItemACombinationItem, bool isTradeItemANonFunctioningDisplayUnit, bool isTradeItemRecalled, string primaryDistributionMethodCode, string rFIDTaggedCode, string serialNumberLocationCode, string tradeItemConditionTypeCode, string tradeItemCountryOfAssembly, string tradeItemCountryOfOrigin, string tradeItemOperatingEnvionment, bool isTradeItemAVariableUnit, int tradeItemId)
    {
        //Creating the basic trade item
        CreateTradeBasicItem(barCodeType, classComplianceRegulationCode, consumerSafteyInformation, doesTradeItemHaveAutoReaderTracker, isBarCodeOnPackageVariableMeasureBarCode, isProductCustomizable, isTradeItemACombinationItem, isTradeItemANonFunctioningDisplayUnit, isTradeItemRecalled, primaryDistributionMethodCode, rFIDTaggedCode, serialNumberLocationCode, tradeItemConditionTypeCode, tradeItemCountryOfAssembly, tradeItemCountryOfOrigin, tradeItemOperatingEnvionment, tradeItemUnitDescriptor);

        //Creating a GTIN for a trade item
        CreateTradeItemIdentification(gtin);
        //Adding a GTIN to a trade item
        AddTradeItemIdentificationOnTradeItem(tradeItemId, GetNewestTradeItemIdentificationId());

        //Creating a targetmarket for a trade item
        CreateBasicTargetMarket(targetMarketCountryCode);
        //Adding targetmarket to a trade item
        AddTargetMarketOnTradeItem(GetNewestTargetMarketId(), tradeItemId);

        //Creating basic dates for trade item
        CreateTradeItemDateBasicDates(effectiveDate, publicationDate, lastChangedDateTime, startAvailability);
        //Adding basic dates to a trade item
        AddTradeItemDateInformationsOnTradeItem(tradeItemId, GetNewestTradeItemDateInformationId());

        //Adding brand owner (GLN) on trade item
        AddBrandOwnerOfTradeItemOnTradeItem(1, tradeItemId);

        //Creating Trade item basic description information
        CreateBasicDescription(brandName, shortDecription, functionalName, descriptionLanguage);
        //Adding brand name to a trade item
        AddTradeItemDescriptionInformationOnTradeItem(GetNewestTradeItemDescriptionInformationId(), tradeItemId);

        //Creating basic unit indicator
        CreateTradeItemBasicUnitIndicator(isTradeItemBaseUnit, isTradeItemAConsumerUnit, isTradeItemADespatchUnit, isTradeItemAnOrderableUnit, isTradeItemAnInvoiceUnit, isTradeItemAVariableUnit);
        //Adding basic unit indicator to trade item
        AddTradeItemUnitIndicator(GetNewestTradeItemUnitIndicatorId(), tradeItemId);

        //Creating GPC on trade item
        CreateGPCOnTradeItem(gPC);
        //Adding GPC to trade item
        AddGDSNTradeItemClassificationOnTradeItem(tradeItemId, GetNewestGPCId());

        //Creating Additional Trade Item Identification Value
        CreateSupplierArticleNumber(articleNumber);
        //Adding article number to GPC
        AddClassificationCategoryOnGDSNTradeItemClassification(GetNewestGPCId(), GetNewestClassificationCategoryId());

        //Creating Trade item basic marking
        CreateBasicPackagingMarking(isPackagingMarkedReturnable, isPriceOnPack);
        //Adding trade item basic marking to trade item
        AddPackagingMarkingToTradeItem(tradeItemId, GetNewestTradeItemMarking());

        //Creating Trade item basic packagin type
        CreateBasicPackagingType(packagingTypeCode);
        //Adding Trade item basic packagin item to trade item
        AddPackagingTypeToTradeItem(tradeItemId, GetNewestPackagingTypeId());

        //Creating Trade item basic measurements
        CreateBasicTradeItemMeasurements(depth, height, width, grossWeight, netWeight, netContent);
        //Adding measurements to trade item
        AddTradeItemMeasurementsOnTradeItem(tradeItemId, GetNewestTradeItemMeasurementsId());

        //Creating Basic Dangerous Substance Information 
        CreateBasicDangerousSubstanceInformation(isDangerousSubstance);
        //Adding danger sub to trade item
        AddDangerousSubstanceInformationOnTradeItem(GetNewestDangerousSubstanceInformationId(), tradeItemId);

    }

我正在使用WCF测试clinet来测试服务。但是,当我运行该服务并调用它时,我得到了这个错误。

  

无法调用该服务。可能的原因:服务处于脱机状态   或无法进入;客户端配置与   代理;现有代理无效。请参阅堆栈跟踪   更多详情。您可以尝试通过启动新代理进行恢复,然后进行恢复   默认配置或刷新服务。

我是“WCF世界”的新手,所以我不知道如何处理这个错误。我目前正在使用wcf创建的自动生成的webconfig文件。我不知道这是否与它有关。我希望你们中的一些人可以帮助我提供的信息,如果你需要更多的答案,我会尝试发布。谢谢!

1 个答案:

答案 0 :(得分:0)

我自己解决了这个问题。我需要在webconfig文件中创建一个新的端点

<services>
      <service name="EPSystem.TradeItemService">
        <endpoint address="ITradeItemService.svc" binding="basicHttpBinding" contract="EPSystem.ITradeItemService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

然后我需要改变我正在调用的一些方法。但基本问题是我的终端无法正常工作。我在上面看到了什么。