Note that there are some explanatory texts on larger screens.

plurals
  1. POwcf service runs fine in java project, but fails in android project
    primarykey
    data
    text
    <p>I have build a wcf web service. When I consume this service in a java project build using eclipse it runs fine but when i try to consume it in android project it gives an exception.</p> <p>Here is how I am consuming it in java project.</p> <p>Step 1: Create directory org and com using wsimport and include it in src folder of java project.</p> <p>Step 2: Add the external jars present in sub-folder "lib" of folder "metro"(This folder is actually referring to the folder where I have installed the metro framework). For this goto project->properties->Java Build Path->Libraries->Add external jars and then browse and select these jar files. </p> <p>Step 3: Create a new class to communicate with the web service. Here is the class that I am using.</p> <pre><code>import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import org.tempuri.IService1; import org.tempuri.Service1; public class JavaClient { public static void main(String[] strArgs) { try { Service1 service1 = new Service1(new URL("http://192.168.1.18/WcfService/Service1.svc?wsdl"), new QName("http://tempuri.org/", "Service1")); IService1 port = service1.getBasicHttpBindingIService1(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://192.168.1.18/WcfService/Service1.svc"); int input = 100; String strOutput = port.getData(input); System.out.println(strOutput); } catch(Exception e) { e.printStackTrace(); } } } </code></pre> <p>Now when I run this java project it ran successfully. </p> <p>Now I want to do the same for an android project. So in the same manner as above I create an android project which is using android platform 2.2 as the build target and then I follow step 1 and step 2 as described above. Thereafter I create a class having the following code.</p> <pre><code>package android.client; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import org.tempuri.IService1; import org.tempuri.Service1; import android.app.Activity; import android.os.Bundle; import android.widget.Toast; public class AndroidClientJavaServerActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { Service1 service1 = new Service1(new URL("http://192.168.1.18/WcfService/Service1.svc?wsdl"), new QName("http://tempuri.org/", "Service1")); IService1 port = service1.getBasicHttpBindingIService1(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://192.168.1.18/WcfService/Service1.svc"); int input = 100; String strOutput = port.getData(input); Toast msg = Toast.makeText(getBaseContext(), strOutput, Toast.LENGTH_LONG); msg.show(); } catch(Exception e) { e.printStackTrace(); } } } </code></pre> <p>After it when I run this android project the application fails in executing successfully. Here is the detailed output of running this android application.</p> <pre><code>07-05 19:50:24.864: W/dalvikvm(279): Unable to resolve superclass of Lorg/tempuri/Service1; (68) 07-05 19:50:24.864: W/dalvikvm(279): Link of class 'Lorg/tempuri/Service1;' failed 07-05 19:50:24.864: E/dalvikvm(279): Could not find class 'org.tempuri.Service1', referenced from method android.client.AndroidClientJavaServerActivity.onCreate 07-05 19:50:24.864: W/dalvikvm(279): VFY: unable to resolve new-instance 85 (Lorg/tempuri/Service1;) in Landroid/client/AndroidClientJavaServerActivity; 07-05 19:50:24.864: D/dalvikvm(279): VFY: replacing opcode 0x22 at 0x0008 07-05 19:50:24.864: D/dalvikvm(279): VFY: dead code 0x000a-0045 in Landroid/client/AndroidClientJavaServerActivity;.onCreate (Landroid/os/Bundle;)V 07-05 19:50:25.044: D/AndroidRuntime(279): Shutting down VM 07-05 19:50:25.081: W/dalvikvm(279): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 07-05 19:50:25.124: E/AndroidRuntime(279): FATAL EXCEPTION: main 07-05 19:50:25.124: E/AndroidRuntime(279): java.lang.NoClassDefFoundError: org.tempuri.Service1 07-05 19:50:25.124: E/AndroidRuntime(279): at android.client.AndroidClientJavaServerActivity.onCreate(AndroidClientJavaServerActivity.java:21) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.os.Handler.dispatchMessage(Handler.java:99) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.os.Looper.loop(Looper.java:123) 07-05 19:50:25.124: E/AndroidRuntime(279): at android.app.ActivityThread.main(ActivityThread.java:4627) 07-05 19:50:25.124: E/AndroidRuntime(279): at java.lang.reflect.Method.invokeNative(Native Method) 07-05 19:50:25.124: E/AndroidRuntime(279): at java.lang.reflect.Method.invoke(Method.java:521) 07-05 19:50:25.124: E/AndroidRuntime(279): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 07-05 19:50:25.124: E/AndroidRuntime(279): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 07-05 19:50:25.124: E/AndroidRuntime(279): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload