Hello, Hoping someone can provide some help.
I have a quite simple .net web service which I intend to communicate with an Android.
On the android side I'm using the ksoap2 library.
Without any parameters being passed, the service works fine.
However, when I try and pass parameters, its like the .net side doesn't recieve them, or the values are dropped, cast to default or something similar.
When I built a .net app to consume the service, parameters are passed and processed by the service just fine, but then .net wraps much of the complicated stuff so I don't see whats going on.
I've used Wireshark to get the xml sent to the service and its supplied below.
XML from .net app. This xml is recieved, processed and returned correctly from the service: (< symbol replaced with 'lt')
lt V:Envelope
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http//www.w3.org.2001.XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:v="http://shcema.xmlsoap.org/soap/envelope/">
lt v:Header/>
lt v:Body>
lt n0:AddNumber id="o0" c:root="1" xmlns:n0="http://tempuri.org/>
lt num1 i:type="d:int">
3
lt /num1>
lt num2 i:type="d:int">
8
lt /num2>
lt n0:AddNumber>
/v:Body>
lt /V:Envelope>
This next copy of xml is recieved by the service, but when I step thru the code in the service, the values for num1 and num2 are 0.
lt s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
lt s:Body>
lt AddNumber xmlns="http://tempuri.org/">
lt num1>
8
lt /num1>
lt num2>
7
lt /num2>
lt /AddNumber>
lt s:Body>
lt /s:Envelope>
Below is the main part of the Android service:
'@Override
'protected Void doInBackground(Void... arg0) {
SOAP_ACTION = SOAP_ACTION + method;
METHOD_NAME = METHOD_NAME + method;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
request.addProperty("num1", 3);
request.addProperty("num2", 8);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
try {
httpTransport.call(SOAP_ACTION, envelope);
}
catch (HttpResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //send request
Object result = null;
try {
result = (Object)envelope.getResponse();
}
catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
response = result.toString();
return null;
And lastly, the web.config of the service.
lt ?xml version="1.0"?>
lt configuration>
lt system.diagnostics>
lt sources>
lt source name="System.ServiceModel.MessageLogging">
lt listeners>
lt add name="messagelistener" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\logsmyMessages.svclog">lt /add>
lt /listeners>
lt /source>
lt /sources>
lt trace autoflush="true" />
lt /system.diagnostics>
lt system.web>
lt compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
lt /system.web>
lt system.serviceModel>
lt diagnostics>
lt messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000"/>
lt /diagnostics>
lt services>
lt service name="CalculatorService.Service1" behaviorConfiguration="CalculatorServiceBehavior">
lt endpoint address="" binding="basicHttpBinding" contract="CalculatorService.IService1">lt /endpoint>
lt endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
lt host>
lt baseAddresses>
lt add baseAddress="http://72.198.31.100:8080/" />
lt /baseAddresses>
lt /host>
lt /service>
lt /services>
lt behaviors>
lt serviceBehaviors>
lt behavior name="CalculatorServiceBehavior">
lt serviceMetadata httpGetEnabled="true"/>
lt /behavior>
lt /serviceBehaviors>
lt /behaviors>
lt /system.serviceModel>
lt /configuration>
Thanks for any help.