2015-02-04 3 views
-3

Я пытаюсь создать веб-сервиса между 2 сайтов, но когда я называю его я получаю следующее сообщение об ошибке:Ошибка в WebService вызова

System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at CreateAttendee..ctor() --- End of inner exception stack trace --- en System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) en System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) en CreateGlothosAttendee.CreateAttendee.Create(String parameters) en c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\godigix\0e20025a\e3315649\App_WebReferences.zfpla_cn.0.cs:línea 46 en events_EstudiosShopper2015.RegisterAttendee(String name, String email, Boolean acceptNotifications) en f:\SVN\goDigix\Web\www.goDigix.com\events\EstudiosShopper2015.aspx.cs:línea 106

У меня есть следующий код для вызова веб-сервиса:

string dataToSend="name=myName&[email protected]"; 
WSCreateAttendee.CreateAttendee webService = new CreateAttendee(); 
string webServiceResponse = webService.Create(dataToSend); 

И у меня есть следующий в моем назначении:

/// <summary> 
/// Web service used to create a new company 
/// </summary> 
[WebService(Namespace = "http://glothos.sureact.com", Name="CreateAttendee")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 

public class CreateAttendee : System.Web.Services.WebService 
{ 
    public CreateAttendee() 
    { 
     //do nothing 
    } 
    [WebMethod] 
    public string Create(string parameters) 
    { 
     //Log into DB the name and email received 
    } 
} 

Может кто-нибудь мне помочь? Я не знаю, что я делаю неправильно.

Спасибо

+1

Мы можем помочь вам, как только вы показать нам код –

+1

Исключение брошено в 'CreateGlothosAttendee.CreateAttendee.Create()' который делает 'новый CreateAttendee()', где вы используйте «словарь [" ключ "]' где «ключ» не существует. – CodeCaster

+0

Здравствуйте, я добавил дополнительную информацию по моему вопросу. Но я не использую «Key» не какой-либо «словарь» в моем веб-сервисе, или я не знаю, что я их использую. – Pimager

ответ

0

Ключ на этом исключении, что говорит @CodeCaster в своем комментарии на ваш вопрос:

The given key was not present in the dictionary. at CreateAttendee..ctor()

Вы должны убедиться, что конструктор используется на CreateAttendee классе проверяет существование кнопочного идентифицированный объект, прежде чем пытаться его извлечь.

В примере:

if (dictionary.ContainsKey("Id")) 
{ 
    value = dictionary["Id"] 
} 
else 
{ 
    // Act when the key does not exist... 
} 
Смежные вопросы