Hello,
Last months I've been busy creating a .NET Webservice with several functions and a website written in html and Javascript which acts as the user interface and calls the webservice methods with JSON. The webservice returned JSON responses and it did work very well. Then I concentrated on the webservice to finish all the functionality and didn't open the website for about 3 weeks.
Today I finished the webservice and decided to continue the work on the website. But when I opened it, I found the JSON communication not working anymore...
The website still sends the JSON requests (Checked this with a network sniffer) but the webservice doesn't respond anymore, so it has to be a problem on the webservice side.
I am trying to find the problem this whole day, but can't find anything.. Here some code snippets which might be usefull
The webservice headers:
[WebService(Namespace = "http://meijberg.topicus.local/zdfmobiel")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
[System.ComponentModel.ToolboxItem(false)]
public class ZDFMobielWebservice : WebService {
The Web.Config file
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="declaratieverwerking">
<section name="db" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="msmq" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<declaratieverwerking>
<db>
<add key="datasource" value="CARTMAN"/>
<add key="database" value="DV_TRUNK"/>
<add key="user" value="****"/>
<add key="password" value="****"/>
<add key="applicationName" value="DeclaratieVerwerking.WebApplication"/>
</db>
<msmq>
<add key="DeclaratieRegelHA304Queue" value=".\Private$\DV_DeclaratieRegelHA304Queue"/>
<add key="DeclaratieRegelAP304Queue" value=".\Private$\DV_DeclaratieRegelAP304Queue"/>
<add key="DeclaratieRegelZH308Queue" value=".\Private$\DV_DeclaratieRegelZH308Queue"/>
<add key="DeclaratieBerichtHA304Queue" value=".\Private$\DV_DeclaratieBerichtHA304Queue"/>
<add key="DeclaratieBerichtAP304Queue" value=".\Private$\DV_DeclaratieBerichtAP304Queue"/>
<add key="DeclaratieBerichtZH308Queue" value=".\Private$\DV_DeclaratieBerichtZH308Queue"/>
<add key="ErrorQueue" value=".\Private$\DV_ErrorQueue"/>
</msmq>
</declaratieverwerking>
<appSettings>
<add key="RecreateHibernateMapping" value="True"/>
<add key="UseUpdateSchema" value="True"/>
</appSettings>
<connectionStrings/>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AjaxEndpointBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="ZDFMobiel.Webservice.ZDFMobielWebservice">
<endpoint adress=""
behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding"
contract="ZDFMobiel.Webservice.ZDFMobielWebservice" />
</service>
</services>
</system.serviceModel>
<spring>
<context>
<resource uri="~/Config/Spring.config"/>
</context>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>
</parsers>
</spring>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Windows"/>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
<namespaces>
<add namespace="Declaratieverwerking.WebApplication.Beheer.Controllers"/>
<add namespace="Declaratieverwerking.WebApplication.Workspace.Controllers"/>
</namespaces>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<trust level="Full"/>
<identity impersonate="true" password="*******" userName="Administrator"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
<httpRedirect enabled="false" destination="http://www.google.nl"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Spring.Core" publicKeyToken="65E474D141E25E07" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.0.20214" newVersion="1.3.0.20214"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
EDIT: Some clientside javascript code which call the webservice:
var xhrGegevens = new XMLHttpRequest();
xhrGegevens.open("POST", "http://meijberg.topicus.local/ZDFMobielWebservice.asmx/getGegevensVerzekerde", true);
xhrGegevens.onreadystatechange = function(){
if (xhrGegevens.readyState === 4) {
var result = eval('(' + xhrGegevens.responseText + ')');
//Functionality
}
}
xhrGegevens.setRequestHeader("content-type", "application/json");
var postData = '{"bsn": "999999999"}';
xhrGegevens.send(postData);
EDIT: The getGevensVerzekerde Method in the webservice:
[WebMethod]
public VerzekerdeGegevens getGegevensVerzekerde(string bsn)
{
ZorgVerzekerde verzekerde = Dao.GetVerzekerde(Convert.ToInt32(bsn));
VerzekerdeGegevens result = new VerzekerdeGegevens();
result.bsn = verzekerde.Bsn;
result.geboortedatum = verzekerde.Geboortedatum.Value.ToShortDateString();
result.geslacht = Convert.ToString(verzekerde.Geslacht);
result.huisnummer = verzekerde.Huisnummer;
result.naam = verzekerde.Naam;
result.postcode = verzekerde.Postcode;
result.voorletters = verzekerde.Voorletters;
int i = 0;
foreach(ZorgPolisInstantie polisInstantie in verzekerde.PolisInstanties)
{
PolisGegevens gegevens = new PolisGegevens();
gegevens.begindatum = polisInstantie.Begindatum.ToShortDateString();
gegevens.einddatum = polisInstantie.Einddatum.Value.ToShortDateString();
if(polisInstantie.Type == (ZorgPolisInstantie.ZorgPolisType) 1)
{
gegevens.eigenrisico = polisInstantie.EigenRisico;
}
else { gegevens.eigenrisico = 0; }
gegevens.polisnummer = Convert.ToString(polisInstantie.PolisNummer);
gegevens.type = (int) polisInstantie.Type;
result.polisgegevens.Add(gegevens);
}
return result;
}
Anyone who knows what the problem might be?