Soap Orchard:在模块中使用Webservice
我需要在我正在编写的模块中使用现有的SOAP Web服务 我的模块的my web.config包含:Soap Orchard:在模块中使用Webservice,soap,web-config,orchardcms,Soap,Web Config,Orchardcms,我需要在我正在编写的模块中使用现有的SOAP Web服务 我的模块的my web.config包含: <system.serviceModel> <bindings> <basicHttpBinding> <binding name="WebShopServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTi
<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>
也就是说,找不到端点元素。
我怀疑这是因为这个web.config不在Orchard根目录中
对此最好怎么做
thx
Reinhard您可以使用
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();
Configuration Configuration=ConfigurationManager.OpenMappedExeConfiguration(
新的ExeConfigurationFileMap{ExeConfigFilename=HostingEnvironment.ApplicationPhysicalPath+@/Modules/MyModule/Web.config},ConfigurationUserLevel.None);
var工厂=新配置ChannelFactory(“IMyService”,配置,null);
var client=factory.CreateChannel();
client.MyMethod();
但我不建议这样做,基本上你必须用自己的设置扩展siteSettings内容部分,并将地址和绑定信息存储在那里。然后在您自己的IoC服务类中使用这些设置
服务类可以创建一个绑定和一个ChannelFactory来调用webservice
var factory = new ChannelFactory<WorkflowServiceRef.IWorkflowService>(
binding,
new EndpointAddress(endpointUri));
factory.Credentials.SupportInteractive = false;
factory.ConfigureChannelFactory();
var channel = factory.CreateChannel();
channel.MyMethod()
var工厂=新的ChannelFactory(
结合
新端点地址(endpointUri));
factory.Credentials.SupportInteractive=false;
ConfigureChannelFactory();
var channel=factory.CreateChannel();
channel.MyMethod()
var factory = new ChannelFactory<WorkflowServiceRef.IWorkflowService>(
binding,
new EndpointAddress(endpointUri));
factory.Credentials.SupportInteractive = false;
factory.ConfigureChannelFactory();
var channel = factory.CreateChannel();
channel.MyMethod()