Note that there are some explanatory texts on larger screens.

plurals
  1. POKSoap HTTP 500 Error
    primarykey
    data
    text
    <p>I am working on android project and I am trying to implement KSoap library. </p> <p>I have created a C# Console application that is hosting a C# WCF soap service and I am trying to get android to talk to the soap service. </p> <p>Below is my C# WCF Service. </p> <pre><code>class SoapServer : ISoapInterface { public string testSoapFunction() { return "Hello World"; } } </code></pre> <p>Below is the Soap Interface</p> <pre><code>[ServiceContract] public interface ISoapInterface { [OperationContract] string testSoapFunction(); } </code></pre> <p>Below is how the soap service is started</p> <pre><code>try { if (Environment.GetEnvironmentVariable("MONO_STRICT_MS_COMPLIANT") != "yes") { Environment.SetEnvironmentVariable("MONO_STRICT_MS_COMPLIANT", "yes"); } if (String.IsNullOrEmpty(soapServerUrl)) { string message = "Not starting Soap Server: URL or Port number is not set in config file"; library.logging(methodInfo, message); library.setAlarm(message, CommonTasks.AlarmStatus.Medium, methodInfo); return; } baseAddress = new Uri(soapServerUrl); host = new ServiceHost(soapHandlerType, baseAddress); BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); var meta = new ServiceMetadataBehavior() { HttpGetEnabled = true, HttpGetUrl = new Uri("", UriKind.Relative), }; host.Description.Behaviors.Add(meta); var debugBehaviour = new ServiceDebugBehavior() { HttpHelpPageEnabled = true, HttpHelpPageUrl = new Uri("", UriKind.Relative), IncludeExceptionDetailInFaults = true }; ServiceEndpoint endpnt = host.AddServiceEndpoint( soapManagerInterface, basicHttpBinding, "EmailServer", new Uri("", UriKind.Relative)); host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Add(debugBehaviour); host.Opened += new EventHandler(host_Opened); host.Faulted += new EventHandler(host_Faulted); host.Closed += new EventHandler(host_Closed); host.UnknownMessageReceived += new EventHandler&lt;UnknownMessageReceivedEventArgs&gt;(host_UnknownMessageReceived); host.Open(); </code></pre> <p>Below is how I am calling the service via android. </p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final String soapAction = "http://tempuri.org/ISoapInterface/testSoapFunction"; final String namespace = "http://tempuri.org/"; final String methodName = "testSoapFunction"; final String url = "http://192.168.1.69:8000/CritiMon"; String resultData = ""; new Thread(new Runnable() { @Override public void run() { String resultData = ""; SoapSerializationEnvelope soapEnv = new SoapSerializationEnvelope(SoapEnvelope.VER11); SoapObject request = new SoapObject(namespace, methodName); soapEnv.setOutputSoapObject(request); HttpTransportSE http = new HttpTransportSE(url); http.debug = true; try { http.call(soapAction, soapEnv); SoapObject result = (SoapObject)soapEnv.bodyOut; if (result != null) { resultData = result.getProperty(0).toString(); Log.d("Soap Result", resultData); } } catch (Exception ex) { Log.e("Soap", ex.toString()); } } }).start(); </code></pre> <p>When I run the above code I am getting the following response:</p> <p>java.io.IOException: HTTP request failed. HTTP Status: 500. </p> <p>Within the soap server I also fire the unknown message received event handler which contains</p> <pre><code>&lt;v:Envelope xmlns:i="http://www.w3.org/2001/ XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://s chemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/enve lope/"&gt; &lt;v:Header&gt; &lt;To v:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addr essing/none"&gt;http://192.168.1.69:8000/CritiMon&lt;/To&gt; &lt;Action v:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/ addressing/none"&gt;http://tempuri.org/ISoapInterface/testSoapFunction&lt;/Action&gt; &lt;/v:Header&gt; &lt;v:Body&gt; </code></pre> <p>Below is the WSDL from <code>http://192.168.1.69:8000/CritiMon?wsdl</code></p> <pre><code>&lt;wsdl:definitions name="SoapServer" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"&gt; &lt;wsdl:types&gt; &lt;xsd:schema targetNamespace="http://tempuri.org/Imports"&gt; &lt;xsd:import schemaLocation="http://192.168.1.69:8000/CritiMon?xsd=xsd0" namespace="http://tempuri.org/"/&gt; &lt;xsd:import schemaLocation="http://192.168.1.69:8000/CritiMon?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/&gt; &lt;/xsd:schema&gt; &lt;/wsdl:types&gt; &lt;wsdl:message name="ISoapInterface_testSoapFunction_InputMessage"&gt; &lt;wsdl:part name="parameters" element="tns:testSoapFunction"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:message name="ISoapInterface_testSoapFunction_OutputMessage"&gt; &lt;wsdl:part name="parameters" element="tns:testSoapFunctionResponse"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:portType name="ISoapInterface"&gt; &lt;wsdl:operation name="testSoapFunction"&gt; &lt;wsdl:input wsaw:Action="http://tempuri.org/ISoapInterface/testSoapFunction" message="tns:ISoapInterface_testSoapFunction_InputMessage"/&gt; &lt;wsdl:output wsaw:Action="http://tempuri.org/ISoapInterface/testSoapFunctionResponse" message="tns:ISoapInterface_testSoapFunction_OutputMessage"/&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; &lt;wsdl:binding name="BasicHttpBinding_ISoapInterface" type="tns:ISoapInterface"&gt; &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http"/&gt; &lt;wsdl:operation name="testSoapFunction"&gt; &lt;soap:operation soapAction="http://tempuri.org/ISoapInterface/testSoapFunction" style="document"/&gt; &lt;wsdl:input&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:output&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;wsdl:service name="SoapServer"&gt; &lt;wsdl:port name="BasicHttpBinding_ISoapInterface" binding="tns:BasicHttpBinding_ISoapInterface"&gt; &lt;soap:address location="http://192.168.1.69:8000/CritiMon/EmailServer"/&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;/wsdl:definitions&gt; </code></pre>
    singulars
    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.
 

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