Tuesday, February 22, 2011

[android-developers] re: uploading files to web server working on .net using c#

Hi guys,
i have an android app, which produces a XML string. i need to
upload it to web server working on .net using C#. i tried sending it
as a string but i got the error as

SoapFault - faultcode: 'soap:Client' faultstring:
'System.Web.Services.Protocols.SoapException: Server did not recognize
the value of HTTP Header SOAPAction:
at
System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at
System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage
message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()

my android client side code is:

commentFileClass commentFileClassobj = new commentFileClass();
commentFileClassobj.commentfile =
correctionActivity.getStringUsedAsXml(); // ------ commentfile
contains the XML string

String NAMESPACE = "http://vivinjoy.org/";

String filename = "android27.xml";
String METHOD_NAME="uploadFile("+commentFileClassobj.commentFile
+","+filename+")";
String SOAP_ACTION = "http://vivinJoy.org/
uploadFile("+commentFileClassobj.commentFile+","+filename+")";
String URL="http://10.0.2.2:12137/WebSite2/webservice.asmx";


SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);

envelope.addMapping(NAMESPACE, "file", String.class);
envelope.addMapping(NAMESPACE, "filename", String.class);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);

try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();

}
catch(Exception e)
{
e.printStackTrace();
}

catch (Exception ex)
{
return ex.Message.ToString();
}

exception is getting caught at line
androidHttpTransport.call(SOAP_ACTION, envelope);

i am confused whether as to whether i should sent the XML string
directly or should i encode it. Pls help me with this ..

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment