Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF 405 webmethod not found issue
    primarykey
    data
    text
    <p>I have a requirement of creating a webservice where the client and the service will talk in Simple Soap (that request and response will be soap), I tried all to find a sample example on net where this thing is already done or some code sample so that I can get started but I think I am bad in searching google, that is why can't find any one so far, Some one suggested to use WCF so get an article </p> <p><a href="http://csharping.com/wcf/building-a-soap-response-envelope-manually-with-the-message-class/" rel="nofollow">http://csharping.com/wcf/building-a-soap-response-envelope-manually-with-the-message-class/</a> </p> <p>But again my problem is not solved, I tried to create an application with this sample (with so many issues :( )</p> <p>Created a console application and the Program.cs is </p> <pre><code>using System; using System.IO; using System.Net; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Text; using System.Runtime.Serialization; namespace ServiceConsole { public class Program { static void Main(string[] args) { using (ServiceHost serviceHost = new ServiceHost(typeof(ServiceClient), new Uri("http://localhost:2000/"))) { ServiceEndpoint serviceEndpoint = new ServiceEndpoint( ContractDescription.GetContract(typeof(IService))); ServiceEndpoint metadataEndpoint = new ServiceEndpoint( ContractDescription.GetContract(typeof(IMetadataExchange))); ServiceMetadataBehavior metadataBehavior = serviceHost.Description.Behaviors.Find&lt;ServiceMetadataBehavior&gt;(); if (metadataBehavior == null) { metadataBehavior = new ServiceMetadataBehavior(); metadataBehavior.HttpGetEnabled = true; serviceHost.Description.Behaviors.Add(metadataBehavior); } serviceHost.AddServiceEndpoint(typeof(IService), new BasicHttpBinding(), "http://localhost:2000/"); serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "http://localhost:2000/WCFService/mex"); serviceHost.Open(); string requestData = "&lt;s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;&lt;s:Header&gt;&lt;h:HeaderItem xmlns:h=\"http://tempuri.org/\"&gt;a header item&lt;/h:HeaderItem&gt;&lt;ActivityId CorrelationId=\"090c553b-bfcc-4e4f-94cd-1b4333fe82a9\" xmlns=\"http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics\"&gt;377a454b-b543-4c6f-b4ac-3981029b60e6&lt;/ActivityId&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\"&gt;a body item&lt;/string&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt;"; byte[] requestDataBytes = Encoding.UTF8.GetBytes(requestData); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/WCFService/"); request.Method = "POST"; request.ContentType = "text/xml; charset=utf-8"; request.Headers.Add("SOAPAction", "http://tempuri.org/IWebService/GetMessage"); request.ContentLength = requestDataBytes.Length; StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()); streamWriter.Write(requestData); streamWriter.Flush(); streamWriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader streamReader = new StreamReader(response.GetResponseStream()); string responseBody = streamReader.ReadToEnd(); Console.WriteLine("Service returned the following response..."); Console.WriteLine(""); Console.WriteLine(responseBody); Console.ReadKey(); serviceHost.Close(); } } } } </code></pre> <p>the <code>app.config</code> which I generated using svcutil.exe is like this</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="BasicHttpBinding_IService" 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"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;security mode="None"&gt; &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="http://localhost:2000/WebService/Service.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="IService" name="BasicHttpBinding_IService" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre> <p>My webservioce is like (it is a WCF website in which the port is provided by me and is 2000</p> <p>Service contract is </p> <pre><code>[ServiceContract] public interface IService { [OperationContract] Message GetMessage(Message s); } [ServiceBehavior] public class Service : IService { public Message GetMessage(Message message) { string body = message.GetBody&lt;string&gt;(); return Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IWebService/GetMessageResponse", "body is " + body); } </code></pre> <p>}</p> <p>and the <code>web.config</code> is</p> <pre><code> &lt;system.serviceModel&gt; &lt;services&gt; &lt;service behaviorConfiguration="ServiceBehavior" name="Service"&gt; &lt;endpoint address="http://localhost:2000/WebService/Service.svc" binding="basicHttpBinding" bindingConfiguration="" contract="IService" &gt; &lt;identity&gt; &lt;dns value="localhost" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;host&gt; &lt;timeouts closeTimeout="00:01:10" /&gt; &lt;/host&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="ServiceBehavior"&gt; &lt;serviceMetadata httpGetEnabled="true" policyVersion="Policy15" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre> <p>My issue is 405 webmethod not body can anyone please tell me what is an issue in this, I am new to WCF before this created a sample and this is my second application</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload