5

SharePoint 2010 के लिए हमने ब्राउज़र द्वारा प्रदर्शित पृष्ठों में जेएस कोड के लिए कुछ तृतीय पक्ष डेटा उपलब्ध कराने के लिए कस्टम वेब सेवाएं (SOAP!) का उपयोग किया। यह संवेदनशील डेटा था इसलिए हमने यह सुनिश्चित करने के लिए प्रतिरूपण का उपयोग किया कि केवल सही उपयोगकर्ता ही इसका उपयोग कर सकें। हमारा समाधान SharePoint 2013 में और काम नहीं करता है। मूल समाधान बहुत जटिल है क्योंकि मैंने एसपी 2013 में एक छोटी और सरल सेवा बनाई है ताकि यह जांच की जा सके कि प्रतिरूपण के साथ एक वेब सेवा कैसे स्थापित की जा सकती है। सेवा आईएसएपीआई के सबफोल्डर को तैनात की गई है।प्रतिरूपण के साथ SharePoint 2013 में कस्टम वेब सेवा

TestService.svc:

यह प्रतिरूपण बिना आधार है, जो काम करता है

<%@ ServiceHost 
    Language="C#" 
    Debug="true" 
    Service="Sandbox.TestService, $SharePoint.Project.AssemblyFullName$" 
    CodeBehind="TestService.svc.cs" 
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 

TestService.svc.cs में कोड के पीछे है:

using Microsoft.SharePoint.Client.Services; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.ServiceModel.Activation; 
using System.ServiceModel; 
using System.ServiceModel.Web; 

namespace Sandbox 
{ 
    [ServiceContract] 
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] 
    public class TestService 
    { 
     [OperationContract] 
     [WebGet(UriTemplate = "GetAllNumbers", 
      ResponseFormat = WebMessageFormat.Json)] 
     List<int> GetAllNumbers() 
     { 
      List<int> result = new List<int>(); 
      result.AddRange(new[] { 1, 1, 2, 3, 5, 8, 13 }); 
      return result; 
     } 
    } 
} 

जब मैं प्रदर्शन http://pc00175/_vti_bin/Sandbox/TestService.svc/GetAllNumbers पर एक प्राप्त करें मुझे अपेक्षित रिजॉन्स [1,1,2,3,5,8,13] प्राप्त होता है। अभी तक ठीक है। अब मैं प्रतिरूपण उपयोग करने के लिए प्रयास करें: "। एक अनाम पहचान एक प्रतिरूपण प्रदर्शन नहीं कर सकते"

using Microsoft.SharePoint.Client.Services; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.ServiceModel.Activation; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Security.Principal; 

namespace Sandbox 
{ 
    [ServiceContract] 
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] 
    public class TestService 
    { 
     [OperationContract] 
     [WebGet(UriTemplate = "GetAllNumbers", 
      ResponseFormat = WebMessageFormat.Json)] 
     List<int> GetAllNumbers() 
     { 
      List<int> result = new List<int>(); 
      WindowsImpersonationContext ctx = ServiceSecurityContext.Current.WindowsIdentity.Impersonate(); 
      try 
      { 
       result.AddRange(new[] { 1, 1, 2, 3, 5, 8, 13 }); 
      } 
      finally 
      { 
       ctx.Undo(); 
      } 
      return result; 
     } 
    } 
} 

अब मैं संदेश के साथ एक System.InvalidOperationException मिल ServiceSecurityContext.Current.WindowsIdentity.Impersonate() पर कॉल करते समय। मुझे डब्ल्यूसीएफ को बताने की जरूरत है कि हमें उस कॉल के प्रतिरूपण की आवश्यकता है। तो मैं एक विशेषता [OperationBehavior(Impersonation=ImpersonationOption.Required)] कहा:

using Microsoft.SharePoint.Client.Services; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.ServiceModel.Activation; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Security.Principal; 

namespace Sandbox 
{ 
    [ServiceContract] 
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] 
    public class TestService 
    { 
     [OperationContract] 
     [WebGet(UriTemplate = "GetAllNumbers", 
      ResponseFormat = WebMessageFormat.Json)] 
     [OperationBehavior(Impersonation=ImpersonationOption.Required)] 
     List<int> GetAllNumbers() 
     { 
      List<int> result = new List<int>(); 
      WindowsImpersonationContext ctx = ServiceSecurityContext.Current.WindowsIdentity.Impersonate(); 
      try 
      { 
       result.AddRange(new[] { 1, 1, 2, 3, 5, 8, 13 }); 
      } 
      finally 
      { 
       ctx.Undo(); 
      } 
      return result; 
     } 
    } 
} 

अब मुझे लगता है SharePoint लॉग में निम्न त्रुटि:

Error when open web service: System.InvalidOperationException: The contract operation 'GetAllNumbers' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('WebHttpBinding','http://tempuri.org/') for contract ('TestService','http://tempuri.org/'.  at System.ServiceModel.Dispatcher.SecurityValidationBehavior.WindowsIdentitySupportRule.ValidateWindowsIdentityCapability(Binding binding, ContractDescription contract, OperationDescription operation)  at System.ServiceModel.Dispatcher.SecurityValidationBehavior.WindowsIdentitySupportRule.Validate(ServiceDescription description)  at System.ServiceModel.Dispatcher.SecurityValidationBehavior.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescriptio... 

तब मैं अनुमान लगाया है कि मैं एक web.config TestService.svc के बगल में जोड़ने के लिए था और TransportCredentialsOnly मोड जोड़ने लेकिन यह मदद नहीं की:

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <webHttpBinding> 
     <binding> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Ntlm"/> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

मैं SharePoint लॉग फ़ाइल में एक ही त्रुटि मिलती है।

मुझे आशा है कि किसी के पास मेरे लिए संकेत मिलेगा।

इसे पढ़ने के लिए धन्यवाद!

पीटर

उत्तर

0

आप बाकी, क्यों आप बस इस के लिए एक ऐप का निर्माण नहीं करतीं उपयोग करना चाहते हैं? शेयरपॉइंट में डब्ल्यूसीएफ सेवा को उजागर करने से यह आसान तरीका है। फिर आप अपनी सुरक्षा सेटिंग्स को कॉन्फ़िगर कर सकते हैं।

यह article आपको इससे मदद करनी चाहिए।

+0

संकेत के लिए धन्यवाद। मैंने इसे आरईएसटी सेवा के रूप में वर्णित गलती की। यह एक सामान्य वेब सेवा है। हम पूरे समाधान को फिर से डिजाइन नहीं करना चाहते हैं क्योंकि यह बहुत जटिल है और हम शेयरपॉइंट 2010 और 2013 समाधान जितना संभव हो सके उतना ही रखना चाहते हैं। –

संबंधित मुद्दे