我使用VS在sharepoint 2010中创建了一个asp.net自定义Web服务,我已将其部署在sharepoint的_layout文件夹下。一切正常。现在我希望这个服务是为跨域公开的,所以任何人都可以使用它或者调用它我也想从任何非微软技术中调用它。像java ....等。 webservice将一个项目添加到sharepoint列表我已经将代码编写在提升的priviliges内。还需要做其他事情以使其对所有人或特定人员都可用。
Now i'm trying to call same web service from console app, but i'm getting error below is my code in console app
ListServiceReference.FRListWebServiceSoapClient obj = default(ListServiceReference.FRListWebServiceSoapClient);
obj = new ListServiceReference.FRListWebServiceSoapClient();
obj.ClientCredentials.Windows.AllowNtlm = true;
BasicHttpBinding binding = new BasicHttpBinding();
// Use double the default value
binding.MessageEncoding = WSMessageEncoding.Mtom;
obj.WebMethod(parameters);
Console.Write("worked");
Console.Read();
And my app config is
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="FRListWebServiceSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server name/_layouts/CustomListWebService/FRListWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="FRListWebServiceSoap"
contract="ListServiceReference.FRListWebServiceSoap" name="FRListWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
I tried increasing buffer size and all but no help. i'm getting exception
System.ServiceModel.ProtocolException was unhandled
Message=The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml"). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<html>
<head>
<title>The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/_layouts/CustomListWebService' Application.<hr width=100% si'.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
What do I need to do at both end console app end and inside layout folder where webservice is deployed
Also I want it to be accessed it for cross domain for specific people in that scenario what are the changes I will require.
Thanks in advance