c# - 从sharepoint的测试机消费wcf

标签 c# wcf sharepoint

背景:

我有一个 WCF,它在我的开发人员、他和他的客户上运行良好。 我将它部署在测试服务器上。

测试由 3 层构建,内容、发布和网络。 content 是我将所有内容放入 Sharepoint 的地方,它只能从 VPN 访问,它是 http,这意味着如果我想从我的开发机器转到我放入 explorer http://testing 的测试内容的网站。

发布是中间的东西,我从不碰它,数据从内容移动到其他 2。

Web 是对公众开放的,是 https 并且有一个负载均衡器,你可以用这个 url https://testnew.mizrahi-tefahot.co.il/_vti_bin/skywcf/skyservice.svc 测试我的 WCF

问题:

在我的开发中,我完美地使用了我的开发 WCF。 MEX 在测试内容和测试网络上都运行良好,您可以在上面的链接中亲眼看到,wsdl 也是如此。

在尝试创建客户端以使用测试网络服务时,我收到此错误消息 (在尝试“添加服务引用”时):

There was an error downloading 'https://testnew.mizrahi-tefahot.co.il/_vti_bin/skywcf/skyservice.svc/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: 'https://testnew.mizrahi-tefahot.co.il/_vti_bin/skywcf/skyservice.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service https://testnew.mizrahi-tefahot.co.il/_vti_bin/skywcf/skyservice.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again.

在我的开发机器中尝试使用测试内容服务时,它创建了服务引用,但是在尝试调用方法时,我得到了当您尝试通过浏览器访问该服务时获得的网页的 html。看着 fiddler ,我看到他给了我“对象移动到这里”的消息,在 url 中添加了某种 token (这是 html):

<html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="%2f_vti_bin%2fSkyWCF%2f(X(1)S(5hwwif450myurs45h5ihnn55))%2fSkyService.svc%3fAspxAutoDetectCookieSupport%3d1">here</a>.</h2> </body></html>

有什么帮助吗?

编辑:网络配置

服务器

<?xml version="1.0"?>
<configuration>
  <system.web>
    <customErrors mode="RemoteOnly"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="Sharepoint.BankMizrahi.Sky.WCF.ServiceBehavior" name="Sharepoint.BankMizrahi.Sky.WCF.SkyService">
        <endpoint address="" binding="basicHttpBinding" contract="Sharepoint.BankMizrahi.Sky.WCF.ISkyService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Sharepoint.BankMizrahi.Sky.WCF.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://mizrahi"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
  </system.serviceModel>
  <appSettings>
    <add key="siteUrl" value="http://mizrahiadmin/sky" />
    <add key="LogName" value="SkyService" />
  </appSettings>
</configuration>

客户

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_ISkyService" 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>
            <wsHttpBinding>
                <binding name="CustomBinding_ISkyService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="None">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://mizrahidev/_vti_bin/SkyWCF/SkyService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISkyService"
                contract="ServiceReference1.ISkyService" name="BasicHttpBinding_ISkyService" />
            <endpoint address="http://mizrahi/_vti_bin/SkyWCF/SkyService.svc"
                binding="wsHttpBinding" bindingConfiguration="CustomBinding_ISkyService"
                contract="ServiceReferenceForTesting.ISkyService" name="CustomBinding_ISkyService" />
        </client>
    </system.serviceModel>
</configuration>

最佳答案

好吧,似乎答案是服务器启用了 sessionState,因此尝试使用 cookie,解决方案只是禁用 cookie

<system.web>
<sessionState mode="Off"/>

这就是测试内容,关于测试网络,我似乎需要找到一种方法来传递剥离 https 的负载平衡

关于c# - 从sharepoint的测试机消费wcf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21161768/

相关文章:

c# - 在 ASP.NET MVC 中填充下拉列表

c# - List<double[,]> 中的问题

c# - WCF 代理生成 : svcutil. exe 与 wsdl.exe

sharepoint - 什么是SharePoint中的服务器场?

c# - 我们可以使用通用列表而不是对象数组 C#

javascript - 在另一个 View 中加载数据后加载部分 View (或多个 View )

c# - 如何设置 WCF Self-Hosted REST 服务?

WCF 客户端应用程序持久连接到非 WCF (DataSnap) 服务器

javascript - 在新窗口中打开自定义网站操作链接 (SharePoint)

file - 如何将带有特殊字符的文件名转换为有效的文件名?