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

  • SEARCH
  • Home
  • 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 7158483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:04:27+00:00 2026-05-28T13:04:27+00:00

I want to call a webservice from a J2ME application : public String alimenterBaseDeDonneesEtapeProsp(

  • 0

I want to call a webservice from a J2ME application :

public String alimenterBaseDeDonneesEtapeProsp( String login, String password,String adresse,String site)
    {
        Object  resultatRequeteSOAP = null;
        SoapObject objetSOAPEtapeProsp;
        HttpTransport connexionServeur;
        SoapSerializationEnvelope envelope;
        String nomService = "urn:Client";
        String urlService = adresse+"/"+site+"/webservice/InterfaceTransfererClient.php";
        String methodeChoisie = "getEtapeProsp";
        try
        {
                    connexionServeur = new HttpTransport(urlService );
                    connexionServeur.debug = true;
                    objetSOAPEtapeProsp = new SoapObject(nomService, methodeChoisie );
                    objetSOAPEtapeProsp.addProperty("user", login);
                    objetSOAPEtapeProsp.addProperty("motpasse",password);
                    System.out.println(objetSOAPEtapeProsp);
                    envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
                    envelope.bodyOut = objetSOAPEtapeProsp;
                    connexionServeur.call(null,envelope);
                    resultatRequeteSOAP = envelope.getResponse();
                    return String.valueOf(resultatRequeteSOAP);
        }
        catch (Exception aE)
        {
             return aE.getMessage();
        }
    }

The ksoap2-j2me-core-2.1.2.jar file is already added to the J2ME project.

The wsdl file is :

<?xml version="1.0" encoding="utf-8"?>
<definitions name="Client" 
        targetNamespace="urn:Client" 
        xmlns:typens="urn:Client" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
        xmlns="http://schemas.xmlsoap.org/wsdl/">

    <!-- partie 2 : Types-->
    <types>
        <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" 
            targetNamespace="urn:Client">
        </xsd:schema>
    </types>
        ...
    <message name="getEtapeProspRequest">
        <part name="user" type="xsd:string"/>
        <part name="motpasse" type="xsd:string"/>
    </message>
    <message name="getEtapeProspResponse">
        <part name="return" type="xsd:anyType"/>
    </message>
        ...
    <portType name="ClientPort">
             ...
        <operation name="getEtapeProsp">
            <input message="typens:getEtapeProspRequest"/>
            <output message="typens:getEtapeProspResponse"/>
        </operation>
    </portType>
    <binding name="ClientBinding" type="typens:ClientPort">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        ...
        <operation name="getEtapeProsp">
            <soap:operation soapAction="EtapeProspAction"/>
            <input name="getEtapeProspRequest">
                <soap:body  use="encoded"   namespace="urn:Client" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output name="getEtapeProspResponse">
                <soap:body  use="encoded" namespace="urn:Client" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
    </binding>

    <!-- partie 7 : Service -->
    <service name="ClientService">
        <documentation></documentation>
        <!-- partie 8 : Port -->
        <port name="ClientPort" binding="typens:ClientBinding">
            <soap:address location="http://192.168.1.123/imfmobile/webservice/InterfaceTransfererClient.php"/>
        </port>
    </service>
</definitions>

The PHP code containing the function which the webservice calls is :

<?php
    header('Content-Type: text/plain; charset=utf-8');
    ini_set("soap.wsdl_cache_enabled", "0");
    $serveurSOAP = new SoapServer('Client.wsdl');
    $serveurSOAP->addFunction('getClient');
    $serveurSOAP->addFunction('getCredit');
    $serveurSOAP->addFunction('getEcheancier');
    $serveurSOAP->addFunction('getUrlPhotos');
    $serveurSOAP->addFunction('getModificationClient');
    $serveurSOAP->addFunction('getModificationCredit');
    $serveurSOAP->addFunction('getModificationEcheance');
    $serveurSOAP->addFunction('getAllPhotoNames');
    $serveurSOAP->addFunction('getEtapeProsp');
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
         $serveurSOAP->handle();
    }
    else
    {
         echo 'désolé, je ne comprends pas les requêtes GET, veuillez seulement utiliser POST';
    }
        ...
        function verifyUser($user, $motpasse) {
        $ok = null ;
        $connec = mysql_connect("192.168.1.123:3306", "root", "mysqlroot");
        mysql_select_db("finance",$connec);
        $query=mysql_query("SELECT  user_code FROM utilisateur WHERE user_login = '".$user."' AND user_passwd = md5('".$motpasse."')");
        if (mysql_num_rows($query)== 1) 
        {
            $ligne = mysql_fetch_array($query);
            $ok = $ligne['user_code'] ;
        }   
        return $ok;
    }
        ...
        function getEtapeProsp($user,$motpasse)
    {
        $user_code    = verifyUser($user, $motpasse) ;
        $resultat="";
        if ( $user_code != null) 
        {
            $datejour = date("Y-m-d");
            $connec   = mysql_connect("192.168.1.123:3306", "root", "mysqlroot");
            mysql_select_db("finance",$connec);
            $query    = mysql_query("SELECT * FROM etape_prospection INNER JOIN type_prospection ON etape_prospection.type_prosp_id = type_prospection.type_prosp_id WHERE prosp_id IN (SELECT prosp_id FROM transfert WHERE user_code ='".$user_code ."' AND date_transfert='".$datejour."') order by etape_prospection.prosp_id");
            while($ligne = mysql_fetch_array($query))
                {
                     $resultat .= $ligne['etape_prosp_id'].';';
                     $resultat .= $ligne['type_prosp_lib'].';';
                     $resultat .= convertDateFormatHH($ligne['etape_prosp_date']).';';
                     $resultat .= $ligne['etape_prosp_comment'].';'; // this is the column containing the accentuated letters
                     $resultat .= $ligne['prosp_id'].';';
                     $resultat .= "\r\n";
                }
        }
        else
        {
            $resultat = "Login ou mot de passe incorrect" ;
        }
        return $resultat;
    }
?>

As you can see I set the encoding/charset both in the wsdl and the PHP.

So why this exception is raised when running the J2ME application :

expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}SOAP-ENV:Fault>@2:299 in java.io.InputStreamReader@e5125d64)
  • 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-28T13:04:27+00:00Added an answer on May 28, 2026 at 1:04 pm

    You need to tell your mysql database / client that you expect to have UTF-8 encoded values (because you insert them as UTF-8 into the SOAP response that is UTF-8 encoded).

    Otherwise the SOAP client would see an invalid byte-squence for the letter in question and throw the exception. Please consult your mysql client library manual to specify the encoding.

    $connec = mysql_connect("192.168.1.123:3306", "root", "mysqlroot");
    mysql_set_charset('utf8', $connec);
    

    The mb_convert_encoding function is only a workaround and you don’t fix the root cause, and it can have side-effects you don’t want to have.

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

Sidebar

Related Questions

I want to call a PHP webservice from my J2ME program. Here is the
I want to call a webservice from jQuery. How can I do that?
I can call a webservice with KSOAP2 from android,now i want to know is
I am a newbie to Android platform. I want to call a webservice from
I'm trying to access an external webservice from Spring 3.1 based application. I want
I want to get the header information from a webservice call. That service returns
I want to call webservice from domain A with the C# code in Domain
I have created a webservice and want to call it from javascript , for
Can I call a webservice from a Controller Action in ASP.Net MVC? public ActionResult
I want to call a webservice using google closures, via jsonp since i am

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.