×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    5

    problem calling web service from j2me app

    Greetings,
    I have been trying to run a j2me application using ksoap2 to access a web service. Thus far I have been unable to do so, due to some error in the call I am making to the service. I was wondering if anyone could spot what I have done wrong in the call:

    This is the expected soap body for the web service:

    <authenticateUser xmlns="http://www.openuri.org/">
    <!--Optional:-->
    <info>
    <!--Optional:-->
    <userID>test</userID>
    <!--Optional:-->
    <password>password</password>
    <resultCode>3</resultCode>
    <!--Optional:-->
    <message>string</message>
    </info>
    </authenticateUser>



    This is the code I am using to call the web service from the midlet:

    SoapObject rpc = new SoapObject("http://localhost:7001/BasicAppWeb/MyWebServices","authenticateUser");
    rpc.addProperty("info", info);


    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
    envelope.bodyOut = rpc;

    HttpTransport ht = new HttpTransport("http://localhost:7001/BasicAppWeb/MyWebServices/AuthenticationService.jws");


    This is the response (error) I am receiving from the server:

    <?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
    <faultcode xmlns:fc='http://www.bea.com/2003/04/jwFaultCode/'>fc:JWSError</faultcode>
    <faultstring>
    Could not resolve method with element 'http://localhost:7001/BasicAppWeb/MyWebServices:authenticateUser' as top element.
    </faultstring>
    <detail>
    <jwErr:jwErrorDetail xmlns:jwErr='http://www.bea.com/2002/04/jwErrorDetail/'>
    com.bea.wlw.runtime.core.request.RequestValidationException: Could not resolve method with element 'http://localhost:7001/BasicAppWeb/MyWebServices:authenticateUser' as top element. [ServiceException]
    at com.bea.wlw.runtime.jws.request.SoapResponse.processException(SoapResponse.java:194)
    at com.bea.wlw.runtime.core.request.BaseResponse.setFault(BaseResponse.java:23)
    at com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke(SyncDispatcherBean.java:218)
    at …………………………………
    …………..more errors…………..

    </jwErr:jwErrorDetail>
    </detail>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    This is how my message is being formatted:

    <v:Envelope xmlns:i="http://www.w3.org/1999/XMLSchema-instance" xmlns:d="http://www.w3.org/1999/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
    <v:Header />
    <v:Body>
    <n0:authenticateUser id="o0" c:root="1" xmlns:n0="http://localhost:7001/BasicAppWeb/MyWebServices">
    <info i:type=":AuthInfo">
    <userID i:type="d:string">test</userID>
    <password i:type="d:string">password</password>
    </info>
    </n0:authenticateUser>
    </v:Body>
    </v:Envelope>


    Thanks in advance for any help, I have been struggling with this one for a bit.

    Thanks!
    Marcos

  2. #2
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: problem calling web service from j2me app

    Are you sure that your "BasicAppWeb/MyWebServices" is implementing the "authenticateUser" method?

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    5

    Re: problem calling web service from j2me app

    Thank you for the response axs, this is the first time i am working with web services so i think my confusion lies in how i am calling the service.

    the structure of the web service i am calling is the following:
    the wsdl is:

    http://localhost:7001/BasicAppWeb/My...eContract.wsdl
    the jws:
    http://localhost:7001/BasicAppWeb/My...ionService.jws

    this is the wsdl for the service:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- @editor-info:link autogen="true" source="AuthenticationService.jws" -->
    <wsdl:definitions xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.openuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.openuri.org/">
    <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.openuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlnspe="http://www.openuri.org/">
    <s:element name="authenticateUser">
    <s:complexType>
    <s:sequence>
    <s:element name="info" type="ope:AuthInfo" minOccurs="0"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="authenticateUserResponse">
    <s:complexType>
    <s:sequence>
    <s:element name="authenticateUserResult" type="ope:AuthInfo" minOccurs="0"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:complexType name="AuthInfo">
    <s:sequence>
    <s:element name="userID" type="s:string" minOccurs="0"/>
    <s:element name="password" type="s:string" minOccurs="0"/>
    <s:element name="resultCode" type="s:int"/>
    <s:element name="message" type="s:string" minOccurs="0"/>
    </s:sequence>
    </s:complexType>
    </s:schema>

    </wsdl:types>
    <wsdl:message name="authenticateUserSoapIn">
    <wsdlart name="parameters" element="s0:authenticateUser"/>
    </wsdl:message>
    <wsdl:message name="authenticateUserSoapOut">
    <wsdlart name="parameters" element="s0:authenticateUserResponse"/>
    </wsdl:message>
    <wsdlortType name="AuthenticationServiceSoap">
    <wsdlperation name="authenticateUser">
    <wsdl:input message="s0:authenticateUserSoapIn"/>
    <wsdlutput message="s0:authenticateUserSoapOut"/>
    </wsdlperation>
    </wsdlortType>
    <wsdl:binding name="AuthenticationServiceSoap" type="s0:AuthenticationServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdlperation name="authenticateUser">
    <soapperation soapAction="http://www.openuri.org/authenticateUser" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdlutput>
    <soap:body use="literal"/>
    </wsdlutput>
    </wsdlperation>
    </wsdl:binding>
    <wsdl:service name="AuthenticationService">
    <wsdlort name="AuthenticationServiceSoap" binding="s0:AuthenticationServiceSoap">
    <soap:address location="http://localhost:7001/BasicAppWeb/MyWebServices/AuthenticationService.jws"/>
    </wsdlort>
    </wsdl:service>
    </wsdl:definitions>



    i am a bit confused as to what i have to pass as the namespace of the soap object, currently i am formatting it like so:

    SoapObject info = new SoapObject("","AuthInfo");
    info.addProperty("userID", "test");
    info.addProperty("password", "password");

    SoapObject rpc = new SoapObject("http://localhost:7001/BasicAppWeb/MyWebServices","authenticateUser");
    rpc.addProperty("info", info);


    then i call the web service like so:

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
    envelope.bodyOut = rpc;

    HttpTransport ht = new HttpTransport("http://localhost:7001/BasicAppWeb/MyWebServices/AuthenticationService.jws");


    i am guessing i am doing something wrong in the call, i would appreciate any help just understand how these calls should be made and what parameters i have to send.

    thanks again!

    marcos

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    13

    Re: problem calling web service from j2me app

    Hi,

    Did you find a solution for this? Can you post it here please.

    Regards.

    Sudheer

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    Re: problem calling web service from j2me app

    Hi mmartins,

    You just try to use one developing simple tool at http://sourceforge.net/projects/ksoap2genstub/. The tool helps you to generate code in J2ME from the WSDL document so that you can easily invoke web services in J2ME.

    Cheeers
    Kinh

Similar Threads

  1. How many are J2me Web service programming masters?
    By premlathiya in forum Mobile Java General
    Replies: 2
    Last Post: 2006-09-16, 06:29
  2. how to access/show missed calls while j2me app is running on 6230
    By hansprueller in forum Mobile Java General
    Replies: 0
    Last Post: 2006-01-12, 06:22
  3. web services on symbian...problem won't be resolved!!!
    By ashrafabdoh in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-09-16, 14:59
  4. strange web service behavior on 6680?
    By asidana in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-06-26, 17:09
  5. Calling web service under Symbian
    By tb337 in forum Symbian C++
    Replies: 0
    Last Post: 2003-11-30, 16:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •