Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Service Web.config:-
----------------------------
XML
<system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding name="jsonpSsl" crossDomainScriptAccessEnabled="true">
                    <security mode="Transport">
                    </security>
                </binding>
            </webHttpBinding>
        </bindings>
        <services>
            <service name="Paytonic.API.UserService" behaviorConfiguration="ServiceBehavior">
                <endpoint address="" binding="basicHttpBinding" contract="Paytonic.API.IUserService" />
                <endpoint address="json" binding="webHttpBinding" contract="Paytonic.API.IUserService" behaviorConfiguration="EndPointBehavior" bindingConfiguration="jsonpSsl"/>
                <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="EndPointBehavior">
                    <webHttp helpEnabled="true" defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json"
                      automaticFormatSelectionEnabled="true" />
                    <enableWebScript/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <useRequestHeadersForMetadataAddress>
                        <defaultPorts>
                            <add scheme="https" port="443" />
                        </defaultPorts>
                    </useRequestHeadersForMetadataAddress>
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <standardEndpoints>
            <webScriptEndpoint>
                <standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
            </webScriptEndpoint>
            <webHttpEndpoint>
                <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json">
                </standardEndpoint>
            </webHttpEndpoint>
        </standardEndpoints>
        <protocolMapping>
            <!--<add binding="webHttpBinding" scheme="https" bindingConfiguration="jsonpSsl" />-->
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>


WCF Service:-
-----------------

C#
[ServiceContract]
public interface IUserService
{
   [OperationContract]
   GetUserDetailsResponse GetUserDetails(GetUserDetailsRequest request);
}
    [DataContract]
    public class GetUserDetailsRequest : Request
    {
        [DataMember]
        public long UserID { get; set; }

    }

    [DataContract]
    public class GetUserDetailsResponse : Response
    {
        [DataMember]
        public UserEntity User { get; set; }
    }
Posted

1 solution

Looks like your android side code expects the data formatted as text/xml with UTF-8 encoding but your service uses json as default format for all interface functions (service webconfig contains >defaultOutgoingResponseFormat="Json"<).

You may either change that default response format to "text/xml" or (if not all functions should use same output format) use function attributes (see VS documentation).

If the webservice is consumed also by other processes so that you can't change it's output formats you may either create a second web service for your android app or change the expected format to json (if possible).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900