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 6178331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:26:16+00:00 2026-05-24T00:26:16+00:00

I have looked at several tutorials using android and ksoap2. My service works fine

  • 0

I have looked at several tutorials using android and ksoap2. My service works fine for sending a string as a parameter from the android client to the soap service.

Now, instead of passing a string, if I want to pass an object. However, it won’t work for me.

On the server side, I have the following web service operation (I’m using jax-ws).

package soap.service.sei;

import javax.jws.WebService;

import soap.service.data.ClientProfile;

@WebService(name = "ImageSei", targetNamespace = "http://image.webservice")
public interface ImageSei {
    public String getImage(ClientProfile c);
}

Very simple. As you can see, the web service operation takes a ‘ClientProfile’ instance. The ‘ClientProfile’ class on the server side looks like:

package soap.service.data;

public class ClientProfile {
    public int ram;
    public String cpu;
    public String bandwidth;
}

Again, very simple. However, should this be the exact same as the ‘ClientProfile’ class in my android (the client) package?

Ok. On the android side, things are a little different. I have the following code snippet for invoking the web service:

    ClientProfile c = new ClientProfile();
    c.ram = 256;
    c.cpu = "22.445";
    c.bandwidth = "712.2";
    prop.setName("c");
    prop.setValue(c);
    prop.setType(c.getClass());
    request.addProperty(prop);

Again, very straightforward. My ClientProfile class in my android project (client side) looks like:

package soap.service.data;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;

public class ClientProfile implements KvmSerializable {
    public int ram;
    public String cpu;
    public String bandwidth;

    public ClientProfile() {}

    public ClientProfile(int $ram, String $cpu, String $bandwidth) {
        ram = $ram;
        cpu = $cpu;
        bandwidth = $bandwidth;
    }

    @Override
    public Object getProperty(int arg0) {
        switch(arg0) {
            case 0 :
                return ram;
            case 1 :
                return cpu;
            case 2 :
                return bandwidth;
        }
        return null;
    }

    @Override
    public int getPropertyCount() {
        return 3;
    }

    @Override
    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
        switch(index) {
            case 0 : 
                info.type = PropertyInfo.INTEGER_CLASS;
                info.name = "ram";
                break;
            case 1 :
                info.type = PropertyInfo.STRING_CLASS;
                info.name = "cpu";
                break;
            case 2 : 
                info.type = PropertyInfo.STRING_CLASS;
                info.name = "bandwidth";
                break;
            default : 
                break;
        }
    }

    @Override
    public void setProperty(int index, Object value) {
        switch(index) {
            case 0 :
                ram = Integer.parseInt(value.toString());
                break;
            case 1 :
                cpu = value.toString();
                break;
            case 2 :
                bandwidth = value.toString();
                break;
            default :
                break;
        }
    }
}

However, on the server side, when the web service operation is invoked by the android emulator using ksoap2, I get ‘null’ when I try to output the ClientProfile instance that is passed as a parameter. It’s a real pain.

All of the tutorials just show you the class parameter from the android side, not the web service side.

I’m assuming there is some sort of serialization issue maybe? Regardless, I get no exceptions. The response from the web service comes back to the android client fine, so this is not a problem.

The underlying problem is that the parameter on the web service side is null. Here is the code for my web service operation:

@Override
public String getImage(ClientProfile c) {
    System.out.println(c); // ***** THIS IS NULL *****
    byte[] imageBytes = null;
    try {
           //...
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    return (imageBytes != null) ? Base64.encodeBase64String(imageBytes) : "";
}

I would really appreciate some help here as I’m completely stuck. I don’t know how to print out the soup messages between my android emulator and the web service running on localhost.

I asked a question about this before but got no reply unfortunately.

Thank you.

  • 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-05-24T00:26:17+00:00Added an answer on May 24, 2026 at 12:26 am

    I found the answer here. For anyone using jax-ws, you must include the annotation for the parameter in the Service Endpoint Interface

    @WebService(name = "ImageSei", targetNamespace = "http://image.webservice")
    public interface ImageSei {
        public String getImage(@WebParam(name = "c")ClientProfile c);
    }
    

    Once you do this, it should work. Output is as follows:

    soap.service.data.ClientProfile@349471
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you plan on using Factor ? Have you looked at it? Checked it
I have some accesses from 192.168.0.71 on my apache logs. I looked up this
I have looked over the Repository pattern and I recognized some ideas that I
I have looked at the SQL Server 2008 feature comparison matrix and it lists
I have looked at NHibernate and EntitySpaces and they both seem to work differently.
I have looked on FaceBook Developer page and found that it's possible to create
I have looked around on the Internet trying to answer this question. It seems
I have looked all of the place for this and I can't seem to
I have looked at the Suggested related questions but none of them are what
I've used jdom in the past, and have looked briefly at XOM and DOM4j

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.