Yeh finally i got the solution,
this is my code
--------------------------------------------------------------------------------------------------------------------------------------
public class HTTPOST 
{
public String getResponseByXML(String URL, String request) 
{
HttpPost httpPost = new HttpPost(URL);
StringEntity entity;
String response_string = null;
try
{
entity = new StringEntity(request, HTTP.UTF_8);
httpPost.setHeader("Content-Type","text/xml;charset=UTF-8");
// httpPost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");
httpPost.setEntity(entity);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httpPost);
response_string = EntityUtils.toString(response.getEntity());
Log.d("request", response_string);
}
catch (Exception e) 
{
e.printStackTrace();
}
return response_string;
}
 public String getResponseByFile(String URL,String xml)
{
HttpPost httpPost = new HttpPost(URL);

FileEntity entity;
String response_string = null;
try 
{
StringEntity ent=new StringEntity(xml,"UTF-8");
//entity = new FileEntity(new 
File(Environment.getExternalStorageDirectory()+File.separator+"request.xml"), 
"UTF-8");
httpPost.setHeader("Content-Type","text/xml;charset=UTF-8");
//httpPost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");
//httpPost.setEntity(entity);
httpPost.setEntity(ent);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httpPost);
response_string = EntityUtils.toString(response.getEntity());
Log.d("request", "**---*** Response : 
"+Html.fromHtml(response_string).toString());
}
catch (Exception e) 
{
e.printStackTrace();
}
return response_string;
}
}
--------------------------------------------------------------------------------------------------------------------------------------
 

public class SoapHTTPPostActivity extends Activity
{
private String URL = 
"http://stage.simformsolutions.com:55109/WebServices/BAAccountService.asmx";;
 @Override
public void onCreate(Bundle savedInstanceState) 
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; 
                                                            
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; 
                                                            
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\";>"+
  "<soap:Body>"+
    "<GetAllAdspacesByBusiness xmlns=\"http://tempuri.org/\";>"+
      "<businessID>"+3+"</businessID>"+
    "</GetAllAdspacesByBusiness>"+
  "</soap:Body>"+
"</soap:Envelope>";
String result=null;
try
{
 InputStream is = new ByteArrayInputStream(xml.getBytes());
result=convertStreamToString(is);
    
//xml = convertStreamToString(getAssets().open("request.xml"));
} 
catch (Exception e) 
{
e.printStackTrace();
}
String request = String.format(result);
HTTPOST httpost = new HTTPOST();
httpost.getResponseByXML(URL, request);
httpost.getResponseByFile(URL,xml);
}

public static String convertStreamToString(InputStream is) throws Exception 
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line+"\n");
}
is.close();
return sb.toString();
}
}
------------------------------------------------------------ END 
-------------------------------------------------------------------------  


On Wednesday, 1 August 2012 19:09:43 UTC+5:30, Rajan wrote:
>
> i am trying to get the response from the SOAP asmx web service but it 
> didn't give proper response
>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  
> here i putting my logcat entry
> -------------------------------------
>
> 08-01 19:08:06.891: W/System.err(1994): 
> org.xmlpull.v1.XmlPullParserException: unterminated entity ref 
> (position:TEXT  ?      ? '
> ?...@1:18 in java.io.InputStreamReader@44e9c180) 
>
> 08-01 19:08:06.891: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.error(KXmlParser.java:269)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.pushEntity(KXmlParser.java:787)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.pushText(KXmlParser.java:855)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:354)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.next(KXmlParser.java:1385)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1415)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:214)
> 08-01 19:08:06.901: W/System.err(1994): at 
> org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:96)
> 08-01 19:08:06.911: W/System.err(1994): at 
> com.simform.soapparsing.MainActivity.onCreate(MainActivity.java:61)
> 08-01 19:08:06.911: W/System.err(1994): at 
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> i also use google for finding this problem but it gives me a rply like : 
>
> In your xml file there are some closing tag is missing.
> e.g <item> <form> 123 </item>
>
> BUT....
>
> my xml is ok and i also validate on W3C
>
> So, what can i do, i didn't understand 
>
> help me
>
> Thank you.
>
>
>

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

Reply via email to