Custom ASP.net webservice in Sharepoint

0

I have created one asp.net custom webservice in sharepoint 2010 using VS, i have deployed it under _layout folder of sharepoint. Everything works fine. Now i want this service to be exposed for cross domain, so any one can use it or call it also i want to be called from any non microsoft tech. like java....etc. the webservice add an item to sharepoint list i have written the code inside elevated priviliges.what else require to be done to make it availible for all or for specific people.

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
asp.net
sharepoint
sharepoint-2010
asmx
asked on Stack Overflow Jan 9, 2014 by user3178955 • edited Jan 29, 2014 by user3178955

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0