Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8873455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:28:08+00:00 2026-06-14T18:28:08+00:00

I’ve got a Web Service, that need a SOAP request to do a simple

  • 0

I’ve got a Web Service, that need a SOAP request to do a simple method on String. Now i wrote app on Android to use this Web Service and i want it to serialize some data and send it to Web Service via SOAP.

Here’s some code:

public class SendedLocation implements Serializable {
    public String MESSAGE;

    public SendedLocation() {
    }

    public SendedLocation(int mId, float mLongitude, float mLatitude) {

        MESSAGE = String.valueOf(mId) + ";" + String.valueOf(mLongitude) + ";" +  String.valueOf(mLatitude);
    }

    public Object getProperty(int arg0) {

        switch (arg0) {
        case 0:
            return MESSAGE;
        }

        return null;
    }

    public int getPropertyCount() {
        return 1;
    }

    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
        switch (index) {
        case 0:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "MESSAGE";
            break;
        default:
            break;
        }
    }

    public void setProperty(int index, Object value) {
        switch (index) {
        case 0:
            MESSAGE = value.toString();
            break;
        default:
            break;
        }
    }

}

public void callWebService(int ID, float Longitude, float Latitude) {
    try {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(
                URL);

        SendedLocation mSended = new SendedLocation(ID, Longitude, Latitude);

        PropertyInfo p1 = new PropertyInfo();
        p1.setName("mSended");
        p1.setValue(mSended);
        p1.setType(mSended.getClass());
        request.addProperty(p1);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        envelope.addMapping(NAMESPACE, "mSended", mSended.getClass());

        MarshalString marshalString = new MarshalString();

        marshalString.register(envelope);

        // Make the soap call.
        androidHttpTransport.call(SOAP_ACTION, envelope);

        Object results = (Object) envelope.getResponse();
        // to get the data String
        // resultData=result.getProperty(0).toString();
        String temp = results.toString();
        System.out.println(temp);
    } catch (Exception aE) {
        System.out.println(aE.toString());
    }
}
public class MarshalString implements Marshal 
{


    public Object readInstance(XmlPullParser parser, String namespace, String name, 
            PropertyInfo expected) throws IOException, XmlPullParserException {

        return String.valueOf(parser.nextText());
    }


    public void register(SoapSerializationEnvelope cm) {
         cm.addMapping(cm.xsd, "string", String.class, this);

    }


    public void writeInstance(XmlSerializer writer, Object obj) throws IOException {
           writer.text(obj.toString());
        }

}

and I’m invoking this callWebService() method in onCreate() like this:

callWebService(ID , (float)location.getLongitude() , (float)location.getLatitude());

then, when i run my app it get fixes from gps but when comes to sending data do Web Service it gives me:

java.lang.RuntimeException: Cannot serialize...

Can somebody explain to me what should I add to make it work? I really have no idea, after trying clue to use Marshal class…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:28:10+00:00Added an answer on June 14, 2026 at 6:28 pm

    Try using SOAP Envelope for sending data,
    Syntax for SOAP Envelope:

    final String envelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
                          "<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
                          "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
                          "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
                          "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                          " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
                          "xmlns:tns=\"urn:registerwsdl\">"+
                          "<SOAP-ENV:Body>"+
                          "<tns:register " +
                          "xmlns:tns=\"urn:registerwsdl\">"+
        "<your_feild_name xsi:type=\"xsd:string\">"+"your_value"+"</your_feild_name>"+
    
    
    
                          "</tns:register>"+
    
                                   // "</SOAP-ENV:Body></SOAP-ENV:Envelope>",Name,Email,Password,Status,Type,Date];
                                   "</SOAP-ENV:Body></SOAP-ENV:Envelope>";
    

    and then use this envelop in this function,
    you can pass multiple value with Soap Envelope

    String CallWebService(String url,
                String soapAction,
               String envelope)  {
              final DefaultHttpClient httpClient=new DefaultHttpClient();
              // request parameters
    
              HttpParams params = httpClient.getParams();
                 HttpConnectionParams.setConnectionTimeout(params, 20000);
                 HttpConnectionParams.setSoTimeout(params, 25000);
                 // set parameter
              HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true);
    
              // POST the envelope
              HttpPost httppost = new HttpPost(url);
              // add headers
                 httppost.setHeader("soapaction", soapAction);
                 httppost.setHeader("Content-Type", "text/xml; charset=utf-8");
    
                 String responseString="";
                 try {
    
                  // the entity holds the request
               HttpEntity entity = new StringEntity(envelope);
               httppost.setEntity(entity);
    
               // Response handler
    
               ResponseHandler<String> rh=new ResponseHandler<String>() {
                // invoked when client receives response
    
                   public String handleResponse(HttpResponse response)
                  throws ClientProtocolException, IOException {
    
                 // get response entity
                 HttpEntity entity = response.getEntity();
    
    
                 // read the response as byte array
                       StringBuffer out = new StringBuffer();
                       byte[] b = EntityUtils.toByteArray(entity);
    
                       // write the response byte array to a string buffer
                       out.append(new String(b, 0, b.length));
    
                       return out.toString();
                }
               };
    
               responseString=httpClient.execute(httppost, rh); 
    
              }
                 catch (Exception e) {
                  Log.v("exception", e.toString());
              }
    
                 xml =  responseString.toString();
                 // close the connection
                 System.out.println("xml file ------"+xml);
              httpClient.getConnectionManager().shutdown();
              return responseString;
             }
    

    and in the end parse the XML output by using any XML parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need a function that will clean a strings' special characters. I do NOT
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.