I am having a frustrating time getting both POST and GET running on my webservice. I need to stop, chill out and figure out what is going wrong.
I broke it down to a very simple method that just takes a string and echos it back. This works on the IIS I have set on my localhost, it works on the production box, but the same configuration is breaking on my test system. Please let me know what I am doing wrong. When accessing:
http://test.softwaredesignexcellence.com/WebPostService/WebPostSvc.svc/json/Test?testtext=test%20me
I am getting a page with a bold header with the text “Service” and the sub header in smaller text stating “Endpoint not found.”.
Why am I getting this message? The same service works on my local host using the query string “http://localhost/Services/WebPostSvc.svc/json/Test?testtext=test%20me”. and I’m getting the response:
<string>Echoing test me</string>
The production server, which I can’t put a link to, since it is internal is giving a slightly different response, but it’s still working fine:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Echoing test me</string>
It is frustrating when I publish locally, hit the local web server, everything is working. I copy the published folder to the production server, type in the similar URL on that server, everything is working, then I ftp the same code, and the same settings to my test server, and it is breaking with the error listed above (Endpoint not found.). What am I not understanding that is keeping me from getting a simple service to run on the test server?
The Interface for the web service:
[ServiceContract( Namespace="http://services.alorica.com/WebPostSvc/1.0" )]
public interface IWebPostSvc
{
[OperationContract]
[WebGet]
string Test(string testtext);
}
This is the simple method I am trying to get working:
[WebService(Namespace = "http://services.alorica.com/WebPostSvc/1.0")]
[ServiceBehavior(Namespace = "http://services.alorica.com/WebPostSvc/1.0")]
public class WebPostSvc : IWebPostSvc
{
public string Test(string testtext)
{
return String.Format("Echoing {0}", testtext);
}
}
My settings are getting unweildy, as I have been fiddling with them trying to get everything working.
UPDATE – I just removed the serviceHostingEnvironment section, it didn’t seem to be necessary, Web Service is still up and working with SOAP, but json is still giving me “Endpoint not found”.
<system.serviceModel>
<!-- Set up Custom Behaviors -->
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SvcMetaBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Set up the binding configuration -->
<bindings>
<basicHttpBinding>
<binding name="SOAPBinding">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="JSONBinding"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="1000000"
maxBufferPoolSize="2000000"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<!-- -->
<service behaviorConfiguration="SvcMetaBehavior"
name="WebPostService.WebPostSvc"
>
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="SOAPBinding"
contract="WebPostService.IWebPostSvc"
/>
<endpoint address="json"
binding="webHttpBinding"
bindingConfiguration="JSONBinding"
behaviorConfiguration="jsonBehavior"
contract="WebPostService.IWebPostSvc"
/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
</system.serviceModel>
Thank you, those that answered so quickly. I found my particular issue, it wasn’t in the configuration as I had thought.
The server I was publishing to did not have .NET 3.5 installed, which is fine, because .NET 2.0 will suffice, but it was missing assemblies. I don’t know why I didn’t get a better error message, but the solution was to look through my references, and switch them to “Copy Local” and do a republish, after which everything was working on that server. I did the “Copy Local” on all the references out of frustration, but I’m sure I only needed to do this to the ones that were not included in the .NET 2.0 framework.