Android Question Consuming a Web Service

RVP

Active Member
Licensed User
Longtime User
I have searched for, and read as many threads as I can, but I am obviously missing something:

Given the following WSDL, how do I use the HttpUtils2 to as an example, request a list of customer via GetCustomerList?

B4X:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. -->
<definitions targetNamespace="ccos" name="CCOSService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="ccos" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <import namespace="http://bbjgenerated/" location="CCOS.wsdl"/>
  <binding name="CCOSServicePortBinding" type="ns1:CCOS" xmlns:ns1="http://bbjgenerated/">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
  <operation name="getOrderDetail">
  <soap:operation soapAction="getOrderDetail"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="getInStockItems">
  <soap:operation soapAction="getInStockItems"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="getCustomerList">
  <soap:operation soapAction="getCustomerList"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="getOrderHeader">
  <soap:operation soapAction="getOrderHeader"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="login">
  <soap:operation soapAction="login"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="placeOrder">
  <soap:operation soapAction="placeOrder"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  <operation name="getOrders">
  <soap:operation soapAction="getOrders"/>
  <input>
  <soap:body use="literal"/>
  </input>
  <output>
  <soap:body use="literal"/>
  </output>
  </operation>
  </binding>
  <service name="CCOSService">
  <port name="CCOSServicePort" binding="tns:CCOSServicePortBinding">
  <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
  </port>
  </service>
</definitions>
 

RVP

Active Member
Licensed User
Longtime User
OK, maybe the issue isn't my syntax. Although I am still wondering if that is correct.. However I just noticed that if I look at the Job on JobDone, I can see the following errormessage

org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8888 refused

What could be the cause of this? I can browse to that address fine (And it is on my computer)
 
Upvote 0

RVP

Active Member
Licensed User
Longtime User
Nope, physical device, Asus Transformer. Although that does probably mean I should be using the actual IP address of my computer where the web server is running?
 
Upvote 0

RVP

Active Member
Licensed User
Longtime User
Ok, I bet that is it, hard to think that a device connected physically to my computer, needs permissions.

On the other part of my question, how would I format the request ?
 
Upvote 0

RVP

Active Member
Licensed User
Longtime User
Erel I have discovered that I can create a jar file from the development environment that is being used to create the Web Service, so I was hoping to be able to use this, and the new AdditionalJar and JavaObject functionality, to access the service. But although I went over your tutorial on Picasso, I cant figure out what syntax I need to use. Ihave attached the jar file
 

Attachments

  • emeraldweb.jar
    12.4 KB · Views: 194
Upvote 0

RVP

Active Member
Licensed User
Longtime User
This is how I am trying to access the classes.


Per the documentation for the development language

wsimport http://192.168.2.210:8888/webservice/CCOS?WSDL


B4A: #AdditionalJar: EmeraldWeb

2. Instantiate the service class. The service class is one
of two classes in the package and has the name
<Service Name>+"Service".


B4X:
 Dim service,port As JavaObject
  service.InitializeNewInstance("EmeraldWeb.ccos.CCOSServiceService",Null)


B4X:
port = service.RunMethodJO("getCCOSServicePort",Null)

Then I try to use one of the Methods

B4X:
Log(port.RunMethod("getCustomerList",Null))

However I am getting an error on the first statement

B4X:
 Dim service,port As JavaObject
  service.InitializeNewInstance("EmeraldWeb.ccos.CCOSServiceService",Null)

java.lang.ClassNotFoundException: EmeraldWeb$CCOSServiceService

I have confirmed that the namespace is lower case ccos, so I assume I have some issue with my naming?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…