I need to build a wcf service, which uses a custom response, in jsonp format, I should get a response like this example:
calling this example method:
http://localhost:49350/Service1.svc/TestConnectionWCF_new?callback=jQuery22406768180963924506_1639677943363&_=1639677943368
I have to get this answer:
jQuery22406768180963924506_1639677943363( {"d":"<ACCESS><MSG><![CDATA[YES]]><\/MSG><\/ACCESS>"} );
I get this instead:
{"TestConnectionWCF_NEWResult":"<ACCESS><MSG><![CDATA[YES]]><\/MSG><\/ACCESS>"}
I have tried so many ways, but I have not gone beyond this, if anyone can kindly help me in any way, even with some advice to go beyond this.
I did a simple service test wcf, this is the code I am using
Interface:
<ServiceContract>
Public Interface IService1
<OperationContract>
<WebGet(ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)>
Function TestConnectionWCF_NEW() As Object
End Interface
The service:
Imports Test_Jsonp_Vb
Imports System.ServiceModel.Activation
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)>
Public Class Service1
Implements IService1
Dim oReturnObject As Object
Public Function TestConnectionWCF_NEW() As Object Implements IService1.TestConnectionWCF_NEW
Try
oReturnObject = "<ACCESS><MSG><![CDATA[YES]]></MSG></ACCESS>"
Return oReturnObject
Catch ex As Exception
oReturnObject = ex.Message
Return oReturnObject
End Try
End Function
End Class
Service Markup:
<%@ ServiceHost Language="VB" Debug="true" Service="Test_Jsonp_Vb.Service1" CodeBehind="Service1.svc.vb" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
WebConfig:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>