4

I want to use WCF service in SharePoint 2010 but have problem.

First, in mapped Sp2010 folder(ISAPI) I created newfolder/myfile.svc and in that file I put a reference to my DLL:

<%@ServiceHost
    Language="C#" Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory,Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    Service="ACIS.WCFService.GraphProccesor, ACIS.WCFService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c4ecbdc9be141501"
%>

Then, in an additional folder (outside ISAPI) I created WCF service logic (class GraphProccesor, namespace ACIS.WCFService)

I compiled, deployed and everything seems ok. in my .dll (c4ecbdc9be141501) - I have namespace and class (same as in above directive), in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\ACISWCFService - I have myfile.svc

But when i try to get url of service in IE i got:

The type 'ACIS.WCFService.GraphProccesor, ACIS.WCFService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c4ecbdc9be141501', provided as the Service attribute value in the ServiceHost directive could not be found.

Please, any suggestions? Did I forget something additional?


Edit #1: Ok, thank you for suggestion but that didn't help. What partially helped is that I added web.config (in first place i forgot that) in _vti_bin/myfolder. Now I getting error message: "Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)"

When I try to get my svc file with "svcutil.exe" in the way "http://dt-slavenl/sites/acis/_vti_bin/ACISWCFService/service.svc" i got message:

WS-Metadata Exchange Error URI: http://dt-slavenl/sites/acis/a1/_vti_bin/ACISWCFService/service.svc Metadata contains a reference that cannot be resolved: 'http://dt-slavenl/si tes/acis/a1/_vti_bin/ACISWCFService/service.svc'. The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'. The remote server returned an error: (401) Unauthorized. HTTP GET Error URI: http://dt-slavenl/sites/acis/a1/_vti_bin/ACISWCFService/service.svc The HTML document does not contain Web service discovery information.


Edit #2: I manage to come "near" my webservice thanks to Marek link. New problem is that when I want to access to web service from IE i got:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

If somebody know how to configure SP app pool or web.config so that I can access from IE, that would be awesome! If not, my new strategy is to create web part (full trust) with image control which has property "imageurl" set to http handler (.ashx) WHICH then will communicate with my wcf service and give response (image) to image.imageurl. If somebody see some potential problems please let me know. Also any suggestion for best way how to implement proxy or client access (from .ashx) will be appreciated!

6
  • When I enter web service URL in IE I got white screen and not any information about status of my request or possible errors. Same thing is with or without "/mex". Now I'm gonna study your links.
    – trip
    Commented Dec 29, 2010 at 8:05
  • Did you apply the AspNetCompatibilityRequirements and BasicHttpBindingServiceMetadataExchangeEndpoint attributes to your class? answers.oreilly.com/… The documentation on this is rather poor, but I think that without the 2nd one the /mex address will not work. Commented Dec 29, 2010 at 9:14
  • 1
    I did everything ok(as in links 1,2,3), but the problem was partially described in 4 link. I learned that my web.config in my _vt_bin file is redundant and that my service/binding/behaviours specs of mywebservice must be defined in sharepoint web.config. And for now, Marek I deeply thank you!! New info follows...
    – trip
    Commented Dec 29, 2010 at 10:25
  • Did you configure your service to use Anonymous authentication? Why not Ntlm? You log in to SharePoint (using integrated authentication, I suppose) and then the same credentials will be automatically passed to the service. BTW, you question is getting too big - consider posting other problems as new questions. Commented Dec 29, 2010 at 14:09
  • I got this error Error File Not Found. Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 1939e647-a05b-491b-be28-0584b26f1070 Error The service '/_vti_bin/WCFSPF/wcfspf.svc' does not exist. Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 12eb7fca-4a29-4c7b-9c37-86fd0cff2856 Date and Time: 10/10/2011 4:06:39 AM
    – user5171
    Commented Oct 10, 2011 at 11:07

3 Answers 3

1

Some useful links:

1
  • 1
    Answer to my problem lied at link 4. I didn't put my wcf configuration on right place (in sp web.config). Thanks to Marek that problem is solved now.
    – trip
    Commented Dec 29, 2010 at 15:57
0

I had a similar issue. When you create the WCF service project in Visual Studio, the strong name in the key.snk file is tied to the namespace of your project. If you change the namespace after you create the project, it breaks the link to the strong name, and that error results. You need to think about how you want your namespace, and name the project with that namespace when you create the project in Visual Studio. In your case, you would name the project "ACIS.WCFService." If you named the project something else, "Fred" for example, the default namespace declaration would be "Namespace Fred."

0

Same issue though I opted to use the Community Kit for SharePoint: Development Tools Edition (cksdev.codeplex.com) and it took care of setting up the service correctly. The only odd issue is that to be able to see/use the Item Template for the WCF Service (CKSDEV), the WCF Service has to be added at the Project level (not at a folder level, which is the recommended approach for adding files in the hive). Still, I just had to set the Deployment Location's Path property of the .svc file. I could then call the MEX endpoint and see the configuration. Tested with the WCF Test Client and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.