Consuming ABAP Webservice from Android device

Dear Experts,
I am ABAP developer (limited knowledge on android) trying to connect  Android device to a.SAP Webservice
Through trial and error and help from SDN and Android forums i managed to link up the ABAP webservice and android using KSOAP2 API.Its working perfectly now but only when i save the username password for SAP access in the webservice settings in transaction SICF.I need to access the service by passing the username and password values through the SOAP request header but so far my efforts have failed me.im presently using the following code to pass my auth values.
I would be grateful if you can point me in the proper direction.
       String NAMESPACE = "mynamespace (works properly without auth)";
        String METHOD_NAME = "mymethod (works properly without auth)";
        String SOAP_ACTION = "mynamespace/mymethod (works properly without auth)";
        String URL = "myURL{works properly without auth)";
        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
        Request.addProperty("Purchaseorder","4500001168");
        Request.addProperty("Username", "myusername");
        Request.addProperty("Password", "mypassword");
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
       envelope.setOutputSoapObject(Request);
       HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
           androidHttpTransport.call(SOAP_ACTION, envelope);
           SoapObject response = (SoapObject)envelope.bodyIn;
           String testValue =  response.getProperty("PoHeader").toString();
           AlertDialog alertDialog = new AlertDialog.Builder(this).create();
           alertDialog.setMessage(testValue);     
           alertDialog.show();
       catch(Exception e)
            e.printStackTrace();
Thanx & Best Regards

Hi,
you can develop a custom Transport class wich extends the: HttpTransportSE class by authentication features.
example:
public class AuthTransportSE extends HttpTransportSE{
     private String username;
     private String password;
     public AuthTransportSE(String url, String username, String password) {
          super(url);
          this.username = username;
          this.password = password;          
     protected ServiceConnection getServiceConnection() throws IOException {
          ServiceConnection midpConnection = new ServiceConnectionSE(url);
          addBasicAuthentication(midpConnection);
          return midpConnection;
     protected void addBasicAuthentication(ServiceConnection midpConnection) throws IOException {
        if (username != null && password != null) {
            StringBuffer buf = new StringBuffer(username);
            buf.append(':').append(password);
            byte[] raw = buf.toString().getBytes();
            buf.setLength(0);
            buf.append("Basic ");
            org.kobjects.base64.Base64.encode(raw, 0, raw.length, buf);
            midpConnection.setRequestProperty("Authorization", buf.toString());
Afterwards you can initialize the Webservice with:
AuthTransportSE androidHttpTransport = new AuthTransportSE(URL, userName, pasword);
Cheers,
Dennis.

Similar Messages

  • Consuming ABAP Webservice in Webdynpro app

    Hi,
    I have wrote a webdynpro app for consuming ABAP webservice. I used the procedure in the link below
    http://wiki.sdn.sap.com/wiki/display/WDJava/ConsumingABAPWebServiceinJavaWD
    Everything seemed to be went well, I created model and Webservice destinations. I have written the code for calling the webservice, which does not return data as part of response. I mean though the RFC returns data at the backend,its not showing the returned records in the webdynpro table.
    I have also tried checking the same by setting external break point. when the webservice is executed from my webdynpro app,it goes to the ABAP debugger and i could clearly see the records in the export parameters of RFC,but the same is not returned in the reponse object.
    Could any one let me know what could be missing. Any help is greatly appreciated?
    I have used the following code in Init method of my View
    Request_ZMYRFC input=new Request_ZMYRFC (model);
    wdContext.nodeRequest_ZMYRFC ().bind(input);
    ZMYRFC  req= new ZMYRFC (model);
    req.setPUserid("EDLAS00C");
    req.setPLtc("E");
    input.setMYRFC (req);
    IWDMessageManager manager = wdComponentAPI.getMessageManager();
        try
        wdContext.currentRequest_ZMYRFCElement().modelObject().execute();
          wdContext.nodeResponse().invalidate();
          wdContext.nodeZMYRFCResponse().invalidate();
          wdContext.nodeReturn_res().invalidate();
         wdContext.nodeItem_res_ret().invalidate();
          wdContext.nodeILtcg_res().invalidate();
          wdContext.nodeItem_res_ltcg().invalidate();
        catch(Exception e)
          manager.reportException(e.getMessage(), false);
    Thanks
    Santhosh

    santosh,
    Check provider system defination in nwa for webservice.After this mapp the provider system and service group after wd app deployed.This is mandatory while consuming webservice in webdynpro for latest versions of CE7.11 or later.for reference check this article/document. http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/50d70a19-45a3-2b10-bba0-807d819daf46
    Thanks,
    Murthy.
    Edited by: Murthy Karaka on Mar 22, 2010 12:59 PM

  • Getting error in consuming google webservices from JspDynPage

    Hi All,
    Getting following error while consuming google webservices from JspDynPage
    An exception occurred while processing a request for :
    iView : GoogleSer.google
    Component Name : GoogleSer.google
    Could not find portal application com.company.global.enterprise.portal.wsdl.webservices.service.
    Code :
    MyGoogle googleService =
    (MyGoogle) PortalRuntime.getRuntimeResources().getService("com.company.global.enterprise.portal.wsdl.webservices.service.MyGoogle");
    GoogleSearchResult result = googleService.doGoogleSearch("google", "SAP", 0, 10, false, "", false, "", "", "");
    ResultElement[] results = result.getResultElements();          
    if(results != null) {
    response.write("<br> Search Result Size " +results.length );
    for (int i = 0; i < results.length; i++) {
    response.write((i + 1) + ": " + results);
    Thanks
    Rudra

    Hi,
    I am still having the same problem, however the scenario in which I am getting varies.
    I am getting this exception:
    "com.sap.engine.services.webservices.jaxm.soap.accessor.NestedSOAPException: IOError while working with the message."
    Some users when trying to login into the portal are getting blank screen and for some the portal launcher page is loading fine and could go to the Home Page.
    When I view the logs I am seeing the Nested Soap Exception.
    Any Ideas??? Starting the J2EE engine also did'nt help.
    Thanks in advance.
    Madhavi

  • Problem while Consuming Java Webservice from WCF client

    Hi,
    I am trying to Consume Java Webservice from WCF client.The webservice main functionality is digital data management.The client can Query Digital data and upload digital data by calling webservice methods.Problem is when i am trying to call webmethod from WCF client its giving "Unrecognised message versions".I have no idea about how the message objects are processed at serverside.but at server side they have used JAXP for XML document parsing.
    The response content type is Multipart/related and applicatio/XOP+XML.
    Can u plz help me how to handle this situation.I have minimum knowledge in Java WS architecture.Basically i am .Net programmer.
    Can U please guide me in a proper way to resolve the problem.

    Hi Abinash,
    I have the same problem. Have you solve that problem?
    I am using a java program to call a webservice too. And I have generated the client proxy definition for Stand alone proxy using NWDS. When I call the method of the webservice I am getting the correct result but along with the result I am getting one error and one warning message in the output.
    The java code to call the webservice is as follows.
    MIDadosPessoaisSyncService service = new MIDadosPessoaisSyncServiceImpl();
    MIDadosPessoaisSync port = service.getLogicalPort("MIDadosPessoaisSyncPort");
    port._setProperty("javax.xml.rpc.security.auth.username","xpto");
    port._setProperty("javax.xml.rpc.security.auth.password","xpto");
    String out = port.MIDadosPessoaisSync("xpto", "xpto");
    System.out.println(out);
    The result I am getting is :
    Warning ! Protocol Implementation [com.sap.engine.services.webservices.jaxrpc.wsdl2java.features.builtin.MessageIdProtocol] could not be loaded (NoClassDefFoundError) !
    Error Message is :com/sap/guid/GUIDGeneratorFactory
    <b>The result of the WS is correct!!!</b>
    The Java project does not have any warning. But the stand alone proxy project has following warnings associated with it.
    This method has a constructor name     MIDadosPessoaisSync.java     
    The import javax.xml.rpc.holders is never used     MIDadosPessoaisSyncBindingStub.java     
    The import javax.xml.rpc.encoding is never used     MIDadosPessoaisSyncBindingStub.java     
    The constructor BaseRuntimeException(ResourceAccessor, String, Throwable) is deprecated     MIDadosPessoaisSyncBindingStub.java
    It is very similar with your problem, could you help me?
    Thanks
    Gustavo Freitas

  • Error Consuming a webservice from ABAP

    Hi all,
      I am consuming an external webservice from abap. I created teh proxy using WSDl file. While testing teh service its giving an exception like this-
    "JAXB unmarshalling exception: Unable to create an instance of de.*******v2.MeldungType; nested exception is javax.xml.bind.UnmarshalExcept
    ion: Unable to create an instance of de.****.MeldungType# - with linked exception:#[java.lang.InstantiationException]"
    With a soapfaultcode: 1..
    can any one help out in arriving at teh reason for this..
    Regards
    Sandeep

    I've seen lots of unmarshalling errors whilst trying to consume web services via Web Dynpro Java...  Usually, it was due to an inconsistency between the WSDL file being used and the underlying web service definition.  It might be worth checking the WSDL you are using is correct and up to date, in case the underlying service interface has changed.
    Also worth checking if you have any simple boolean type parameters defined as part of the service interface - they have to have a value assigned when you call the service and cannot be null.
    HTH.

  • Consuming Sharepoint webservice from Abap

    Hi, I have a need to access a Sharepoint database from SAP.  I am using the search.aspx webservice that sharepoint offers, or at least trying to.  I set up an abap proxy from the WSDL that sharepoint supplied (which was not the best WSDL).  From my ABAP I need to call the sharepoint service and I am having a little difficulty getting a result back.
    Here is the ABAP code I have so far:
    DATA: gr_query  TYPE REF TO zgms_cycletimeco_query_service,
          gs_input  TYPE zgms_cycletimequery_soap_in,
          gs_output TYPE zgms_cycletimequery_soap_out.
    DATA: oref   TYPE REF TO cx_root,
          text   TYPE string,
          oref2   TYPE REF TO cx_root,
          text2   TYPE string.
    CREATE OBJECT gr_query.
    CONCATENATE 'get_text( ).
    ENDTRY.
    I am trying to retrieve the record that contains HE2009-0624-084648 with no luck.
    The error message I get says no results found.
    Does anyone know what I am doing wrong?  Do I need to specify the field in sharepoint that contains this data?
    Thanks in advance,
    René

    Thanks for your reply.  I actually tested today in SE80 on the proxy, and the request was formatted as:
    <n0:Query xmlns:n0="urn:Microsoft.Search" xmlns:prx="urn:sap.com:proxy:PLD:/1SAI/TAS4ADD6B94366302A825F7:700:2007/10/04">
    <n0:queryXml>This is a string 6</n0:queryXml>
    </n0:Query>
    When I execute it, the reponse is:
    - <n0:QueryResponse xmlns:n0="urn:Microsoft.Search" xmlns:prx="urn:sap.com:proxy:PLD:/1SAI/TAS4ADD6B94366302A825F7:700:2007/10/04">
      <n0:QueryResult><ResponsePacket xmlns="urn:Microsoft.Search.Response"><Response domain=""><Status>ERROR_BAD_REQUEST</Status><DebugErrorMessage>Data at the root level is invalid. Line 1, position 1.</DebugErrorMessage></Response></ResponsePacket></n0:QueryResult>
      </n0:QueryResponse>
    I don't really know what the format would be in between the queryXml tags.  If anyone knows, please help!
    Thanks.

  • Consuming ABAP webservice in Java

    Hi Gurus,
    We are publishing webservices from SAP and Java team is consuming them. For accessing the webservice  from java , we are maintaining User name and Password in SICF for that service.
    Now if we donot maintain the User name and Password in SICF for that service then Exception "Unauthorised " is coming in Java.
    We want to pass the User name and Password from Java. How to achieve this.
    Thanks
    Jitendra

    Hi John,
    thnx for quick response. i have given WSDL to Java team but they are unable to find " Logon service in the WSDL".
    Can u tell us for which XML tags we should search.
    Thanks
    Jitendra

  • Consuming ABAP Webservice in webdynpro java.

    hi All,
    i tried the all ways provided in sdn to create a webservice in ABAP when i test its working fine on j2ee server.
    when i call the same webservice from webdynpro its throughing this error can any body kindly help me in this.
    java.rmi.RemoteException: Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.InvalidResponseCodeException: Invalid Response Code: (502) Proxy Error ( The ISA Server denied the specified Uniform Resource Locator (URL).  ). The requested URL "xxxxxxxxxx".
    Thank you.
    venkat.

    Hi Venkatramana,
    The class of the ProxyGenerator is com.inqmy.lib.wsdl.ProxyGenerator. It is located in <SAPj2eeEngine_install_dir>/cluster/server/additional-lib/inqmysoap.jar or <SAPj2eeEngine_install_dir>/alone/additional-lib/inqmysoap.jar file. In addition the following JAR files must be included in your classpath - mail.jar, activation.jar, inqmyxml.jar, inqmysoap.jar, located in <SAPj2eeEngine_install_dir>/cluster/server/additional-lib/ or <SAPj2eeEngine_install_dir>/alone/additional-lib/ directory. You need also the inqmy-lib.jar file in <SAPj2eeEngine_install_dir>/cluster/server/lib/ or <SAPj2eeEngine_install_dir>/alone/lib/ directory in order to run the generator.
    SAP Note : <a href="https://websmp201.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=547847&_NLANG=E">547847</a>
    Before deploying make sure the JCo’s are up and running
    Go to http://server:port/webdynpro/dispatcher/sap.com/tcwdtools/Explorer to check the status of JCo’s.
    Regards,
    Mithu

  • Consuming PI Webservice from Webdynpro Java Not working

    Hello SAP,
    Environment: CE 7.2.
    Resolution expected immediately, Helpful answer is highly appreciated.
    Is the namespace should not exceed 60char for PI Webservice, for executing the webservice from Webdynpro Java.
    I tried with all the options in executing the PI Service from Webdynpro Java, None of the options worked. I am facing the below error while I was calling the PI Webservice.
    I don't see any problem from Webdynpro Java, what ever the procedure I have followed is the standard procedure.
    Fortunately when I execute the service from Webservice Navigator, it is working as expected. The same webservice when I consume it from Webdynpro Java it is not working
    Options tried so far:
    1) Published the Services to Service Registry and there by consuming the PI Service from Service Registry - Not worked
    2) Tweaked the URL with few options - Not worked (Tweaking the URL, ex: portType, Binding)
    3) Changing the Business Systems in PI and there after calling the service - Not worked
    4) Initializing the code, instead of creating Service Controller and calling the PI Service - Not worked.
    5) Created a Provider System and tried to call the PI Webservice from Provider System - Not Worked
    For all the Options, I am facing the same error which is provided in the screenshot.
    Below procedure which I have followed for calling the PI Webservice:
    1) Created Adaptive Webservice Model
    2) Provided PI Webservice URL (It prompts for PI System UserId and Password)
    3) Selected Option - No Service Group Configuration
    4) Provided Logical Destination
    6) Completed creation of Model
    7) Added the model as a UsedModel
    8) Right Click on Comp Contr. and selected Apply Template and Created a ServiceController for the model (Entire mapping to comp contr, Initializing the nodes is taken care by Service Contr.)
    9) Created an Template Action button and there by calling execute method which is auto rendered from CompContr..
    10) Build the project.
    11) Activated the code and Run the Application.
    12) Getting the below error which is showed in the message.
    ERROR MESSAGE:
    Exception on execution of web service on destination 'GetPIHRPeopleData' for operation 'SI_CreateHRPeopleData_OS' in interface 'SI_CreatePeopleCompany_OS'

    Hi Sankar,
    If the webservice is working fine in the Wsnavigator then there is some problem with importing the webservice in webdynpro for Java. Please check the required parameter for creating the Adaptive Webservice Model. After adding in the used model and compoent controller binding, you need to write code for to execute the webservice model.
    Please check the code for initialization and execution for the webservice and then test it.
    Best Regards,
    Arun Jaiswal

  • Consume ABAP Webservice using AJAX javascript

    Hi,
    We created webservice for  ABAP BAPI. And I want to consume this using AJAX javascript.
    But I am getting "Access Denied" javascript error.
    Please let me know how to pass the credentials while trying to consume this webservice
    I tried below code, but its NOT workng
    var URL ="http://hostname/sap/bc/srt/rfc/sap/servicename?sap-client=400&sap-user=testuser&sap-password=testpassword";
    xmlhttprequest.open("POST", URL, true);
    Please let me know your thoughts ...
    Thanks
    Edited by: sona p on Feb 27, 2010 12:18 AM

    Hi,
    Thanks for your response. I did the same as mentioned in the link provided by you. But it is not working . I am still getting "Access denied" javascript error in the second line ( xmlhttprequest.open) . Below is my code.
    var auth = make_base_auth('userid','password');
    xmlhttprequest.open("POST", URL, true);
    xmlhttprequest.setRequestHeader('Authorization', auth);
    xmlhttprequest.setRequestHeader ("Content-Type", "text/xml");
    xmlhttprequest.onreadystatechange = getDataList;
    xmlhttprequest.send(SOAPEnvelope);
    Please let me know your thoughts. Thanks again for your response.

  • How to import photos and videos from Android device?

    Hello
    I just bought Photoshop Elements 11 recently and I'm trying to import photos and videos from my phone, Samsung Galaxy SIII, but having a little trouble.
    When I go to "Import from Camera or Card Reader" option and choose my phone from the "Get photos from" drop down menu in "Source" section the "Photo downloader" finds
    every single photo and/or video stored on the device and it's memory card but I'm trying to import only photos and/or videos I've shot my self with the phone, witch is kept
    in an folder named DCIM, but I simply can't figure out how to so my question is:
    How do I import photos and/or videos from my Android device?

    Try clicking Advanced button (bottom left) in the downloader dialog. You should then be able to select and deselect thumbnails and import only the ones you give the checkmark.

  • IOS 5 Mail crashes when replying to an email from Android device

    When ever I reply to an email sent to me from an Android device on my iPad or iPhone the mail client crashes when I hit send.
    This is occurring with all iOS users in our organisation.
    Is anyone else experiencing this problem?

    Just completed a conference call, with a rep for Sprint Corporate accounts and an Apple Senior Technician.
    The company for which I work has a large fleet of wireless devices, including iPhones, iPads and Adroid phones.
    Through several tests, Apple, Sprint and I narrowed it down to this:
    Apple iOS devices are UNABLE to reply to Android e-mails:
    When the Android user has modified the signature, AND the e-mail is sent through a Microsoft Exchange Server, using ActiveSync.
    Apple iOS devices ARE able to send replies to Android e-mails:
    When the Android user has modified the signature AND the e-mail is sent via a server other than Microsoft Exchange.  (e.g. Gmail and Yahoo Mail)
    Apple iOS devices ARE able to send replies to Android e-mails:
    Which still have the defualt signature (i.e. "Sent from my HTC Evo", etc.)  The type of e-mail server does not appear to affect the result in this case.
    Next stop:  Microsoft Exchange Technical Support.  (Of course, Microsoft will blame it on Android and Apple.)
    Don't know what we'll do, then.

  • How to consume a webservice from sap crm

    Hi All,
    How to consume and access an external webservice from sap crm?
    Suggest me.
    Regards,
    Sanjani
    Edited by: Sanjani on Dec 6, 2010 3:09 PM
    Edited by: Sanjani on Dec 10, 2010 1:08 PM

    Please check the wiki link mentioned below. It will help you to an extent.
    http://wiki.sdn.sap.com/wiki/display/CRM/CreatingWebServiceinSAP+CRM
    Rg,
    Harshit

  • Consuming a webservice from a message bean?

    i set up a webservice proxy in another application project.
    i want another project's Message Bean to consume the webservice proxy
    that is in the other project?
    TIA

    just moved the web service proxy to the same application..

  • How to view videos on apps from android device

    Trying to view my videos on Facebook but need to set up flash player on Samsung galaxy 5 phone? Any suggestions?

    Hi jenniferr52464914,
    Please refer another forum thread given below:
    when will flash player be available for Android devices.
    Let me know if this answers your query.
    Regards,
    Anubha

Maybe you are looking for