2012-03-07 18 views
6

इसलिए कुछ दिनों से अब मेरी परियोजनाओं के भीतर वेब संदर्भों के बारे में सीखना अब मुझे एक अजीब समस्या आई है।वेब संदर्भों का उपयोग कर

एक सरल सांत्वना अनुप्रयोग मैं इस किया था का उपयोग करना:

namespace Webservices09004961 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 

      { 
       Convert.ConvertTemperatureSoapClient client = 
       new Convert.ConvertTemperatureSoapClient(); 
       while (true) 
       { 
        Console.Write("Enter temperature in Celsius: "); 
        double tempC = double.Parse(Console.ReadLine()); 
        double tempF = client.ConvertTemp(tempC, Convert.TemperatureUnit.degreeCelsius, Convert.TemperatureUnit.degreeFahrenheit); 
        Console.WriteLine("That is " + tempF + " degrees Farenheit"); 
       } 
      } 
     } 
    } 
} 

मैं सेवा संदर्भ "कन्वर्ट" इस लिंक से संबंधित में जोड़ लिया है: http://www.webservicex.net/ConvertTemperature.asmx?WSDL

हालांकि मैं इस त्रुटि मिलती है:

An endpoint configuration section for contract 'Convert.ConvertTemperatureSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

ऐसा इसलिए है क्योंकि आपके पास केवल एक सेवा संदर्भ आवंटित किया जा सकता है पहर? कारण मैं पूछता हूं क्योंकि एक ही प्रोजेक्ट के भीतर मेरा स्थानीय सेवा संदर्भ अभी भी ठीक काम करता है? फिर भी यह नहीं करता है? (यह तब हुआ जब मैंने इसे पहली बार बनाया)

या यह एक अलग समस्या है?

एसओएपी पर सीमाएं क्या हैं?

+2

उत्तर आपकी .config फ़ाइल में होगा। –

+0

हाँ मैंने इसे पाया। धन्यवाद वैसे भी –

उत्तर

10

यह त्रुटियां आम हैं जब आप एक svc संदर्भ को हटाने का प्रयास करते हैं और इसे फिर से जोड़ते हैं। अपने ऐप/web.config फ़ाइल की जांच करें, आपके पास कनवर्ट करने के लिए डुप्लिकेट प्रविष्टियां होनी चाहिए। ConvertTemperatureSoap। उनमें से एक को हटा दें और यह ठीक काम करेगा।

+1

टिप्पणी के लिए धन्यवाद डेविता मुझे यह मिला :) –

+0

आपका स्वागत है :) – Davita

+1

लॉल इस उत्तर ने मुझे दो बार बचा लिया है! – Pomster

0
 <endpoint address="http://www.webservicex.net/ConvertTemperature.asmx" 
      binding="basicHttpBinding" bindingConfiguration="ConvertTemperatureSoap" 
      contract="Convert.ConvertTemperatureSoap" name="ConvertTemperatureSoap" /> 
     <!--<endpoint address="http://www.webservicex.net/ConvertTemperature.asmx" 
      binding="customBinding" bindingConfiguration="ConvertTemperatureSoap12" 
      contract="Convert.ConvertTemperatureSoap" name="ConvertTemperatureSoap12" />--> 

ठीक है मुझे पता चला कि त्रुटि मेरी कॉन्फ़िगरेशन फ़ाइल में डबल प्रविष्टि से संबंधित थी। अजीब यकीन नहीं है कि ऐसा क्यों किया।

अब काम करता है।

संबंधित मुद्दे