我有問題可以從沙盒Visual Web Part Sharepoint 2010調用Azure WCF服務。所有安裝的本地計算機Windows 7 64 Ultimate - Sharepoint Foundation 2010用於開發Web部件和帶有Azure SDK的Visual Studio 2010。 Web Service從本地Azure模擬器啓動,Web部件在本地計算機中啓動。 當我使用非標準大師「添加服務引用」,以Web部件,生成的app.config,則拋出錯誤:Azure WCF服務+ Sharepoint 2010沙盒Visual Web部件=錯誤
ServiceReference1.Service1Client serv = new ServiceReference1.Service1Client();
Label1.Text = serv.GetData(9);
找不到,在ServiceModel引用合同「ServiceReference1.IService1」默認終結點元素客戶端配置部分。 這可能是因爲沒有爲您的應用程序找到配置文件,或者是因爲在客戶端元素中找不到匹配此合同的端點元素。
當我創建連接編程 -
EndpointAddress adr = new EndpointAddress(new Uri("http://127.0.0.1:81/Service1.svc"));
BasicHttpBinding basic = new BasicHttpBinding();
ChannelFactory<ServiceReference1.IService1Channel> fact = new ChannelFactory<ServiceReference1.IService1Channel>(basic, adr);
Label1.Text = fact.CreateChannel().GetData(8);
扔錯誤:
請求類型的「System.Net.WebPermission,系統權限,版本= 2.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089「。
的app.config的WebPart:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://127.0.0.1:81/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
的web.config Azure的WCF服務:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<!-- To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section.
To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
To avoid performance degradation, remember to disable tracing on production deployments.
<system.diagnostics>
<sharedListeners>
<add name="AzureLocalStorage" type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"/>
</sharedListeners>
<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
</sources>
</system.diagnostics> -->
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
附:當所有人都轉到工作部署時 - Azure和Sharepoint Online - 再次出現錯誤。我以編程方式創建連接,因爲閱讀,在沙盒 解決方案app.config未與Web部件一起部署,我們必須在web.config Sharepoint 2010中複製他的代碼 - 但在Sharepoint Online中,此文件已從開發者處關閉!