2013-06-03 1 views
1

Я оконный разработчик с очень небольшим знанием веб-приложений и ASP. Я пытаюсь создать C# dll (который вызывает вызов webservice) для кого-то, который вызывается из приложения CLASSIC ASP.Вызов веб-службы из библиотеки C# из CLASSIC ASP

Все началось с тестового приложения WinForms, которое успешно загрузило WSDL и вызвало эту веб-службу. Теперь необходимо принять тестовое приложение, переместить его в DLL и вызвать DLL из приложения ASP. Я наивно оставил файл AppConfig там, и когда это дллы называли, он получил это хорошо известную ошибку:

Could not find default endpoint element that references contract Service1.MyService in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

Я понимаю, что классические осины не имеют конфигурационные файлы - Я прочитал много сообщений об этом, и большинство из них упоминают использование BasicHTTPBinding и предоставление конечного адреса на лету. Как мне это сделать? Любые примеры?

Я видел этот ответ:

All I needed to do is to create a BasicHTTPBinding and provide an endpoint address on the fly.Then create a new instance of the web service using the created binding and endpoint address.

Но я не уверен, как это сделать.

Это AppConfig, которая работала для приложения WinForms:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IMyService"> 
       <security mode="Transport"> 
        <transport clientCredentialType="Certificate" proxyCredentialType="None" 
         realm="" /> 
       </security> 
      </binding> 
      <binding name="BasicHttpBinding_ICustomerService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://MyService.svc" 
      behaviorConfiguration="custom" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IMyService" contract="MyService.IMyService" 
      name="BasicHttpBinding_IMyService" /> 
    </client> 


    <behaviors> 
    <endpointBehaviors> 
     <behavior name="custom"> 
     <customInspector /> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
    <extensions> 
    <behaviorExtensions> 
     <add name="customInspector" type="CustomBehaviors.CustomBehaviorExtensionElement, CompeteDataServiceTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
    </behaviorExtensions> 
    </extensions> 


</system.serviceModel> 

ответ

1

Вам нужно будет настроить службу с помощью кода, так как нет ни одного файла конфигурации в этом случае. См. Configuring WCF Services in Code.

Смежные вопросы