2012-08-14 3 views
0

필자가 작성한 모듈에서 기존 SOAP-Web 서비스를 사용해야합니다.오차드 : 모듈에서 웹 서비스 사용하기

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="WebShopServiceSoap" 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="http://10.0.0.123/LCWebservices/LC.MiscService/webshopservice.asmx" 
    binding="basicHttpBinding" bindingConfiguration="WebShopServiceSoap" 
    contract="LCWebshopServiceReference.WebShopServiceSoap" name="WebShopServiceSoap" /> 
</client> 

하지만 내 모듈은 엔드 포인트 요소를 찾을 수 없음을, 대략 번역

Oops. Something went wrong ... sorry 
An unhandled exception has occurred and the request was terminated. 
Please refresh the page. If the error persists, go back 

Es wurde kein standardmäßiges Endpunktelement gefunden, das auf den Vertrag 
"LCWebshopServiceReference.WebShopServiceSoap" im ServiceModel- 
Clientkonfigurationsabschnitt verweist. 
Dies kann folgende Ursachen haben: Für die Anwendung wurde keine 
Konfigurationsdatei gefunden, oder im Clientelement wurde kein 
Endpunktelement gefunden, das diesem Vertrag entsprach. 

를 던졌습니다 : 내 모듈의

내 Web.config의이 포함되어 있습니다. 이 사실은이 web.config가 Orchard-Root에 있지 않기 때문인 것으로 의심됩니다.

가장 좋은 점은 무엇입니까 ??

들으 라인 하르트

답변

0

당신은

Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(
       new ExeConfigurationFileMap { ExeConfigFilename = HostingEnvironment.ApplicationPhysicalPath + @"/Modules/MyModule/Web.config" }, ConfigurationUserLevel.None); 

     var factory = new ConfigurationChannelFactory<IMyService>("IMyService", configuration, null); 
     var client = factory.CreateChannel(); 
     client.MyMethod(); 

를 사용하여 Web.config의를 사용할 수 있습니다하지만 난이 basicly 자신의 설정으로 siteSettings에게 내용 일부를 확장 할 수 있고,이 추천하고 주소를 저장하지 않을 및 거기에 정보 바인딩. 그런 다음 자신의 IoC 서비스 클래스에서 해당 설정을 사용하십시오.

서비스 클래스는 바인딩과 ChannelFactory를 만들어서 웹 서비스를 호출 할 수 있습니다.

var factory = new ChannelFactory<WorkflowServiceRef.IWorkflowService>(
      binding, 
      new EndpointAddress(endpointUri)); 
factory.Credentials.SupportInteractive = false; 
factory.ConfigureChannelFactory(); 
var channel = factory.CreateChannel(); 

channel.MyMethod() 
관련 문제