Foren

Error generating custom services with builder sdk for android

Miguel Pereira, geändert vor 7 Jahren.

Error generating custom services with builder sdk for android

New Member Beiträge: 6 Beitrittsdatum: 26.03.16 Neueste Beiträge
Hi everybody

I am facing with a problem trying to use mobile builder. Afterl fill the guided process the tool return me
GRAVE: org.json.JSONException: JSONObject["context"] not found.


I checked my custom services and in my localhost appears in "Context name" the name of my custom portlet called "devshaker" and indeed it list to me the only method I created.

The URL it generate is
http://localhost:8112/en/api/jsonws?contextName=devshaker
but as I read in error is looking for "context" exact string. This error happens if I try to create the same for other context natives of liferay.

What I am doing bad? context changes using OsGI? How can i create my custom sdk jar?

Indeed I ask... it has sense to use it if you want to use JSON webservices in to communate between android app and server? Or is preferible to use others like "Retrofit"

Any help will be thank.
Miguel Pereira, geändert vor 7 Jahren.

RE: Error generating custom services with builder sdk for android

New Member Beiträge: 6 Beitrittsdatum: 26.03.16 Neueste Beiträge
Well... replying to myself... maybe the point is I could not generate the jar containing wsdd in my /build/lib folder of my *.service component.

I modified my project build.gradle and now is like this:

buildscript {
	dependencies {
		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.service.builder", version: "1.0.9"
		classpath group: "com.liferay", name: "com.liferay.portal.tools.service.builder", version: "latest.release"
		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.wsdd.builder", version: "latest.release"
    
	}
}

apply plugin: "com.liferay.portal.tools.service.builder"
apply plugin: "com.liferay.portal.tools.wsdd.builder"

dependencies {

		compile group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
		compile group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
		compile group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.2"
		compile  project(':modules:devshaker:devshaker-api')
	
}

buildService {
	apiDir = "../devshaker-api/src/main/java"
	osgiModule = true
	propsUtil = "com.devshaker.service.util.PropsUtil"
}

version = '1.0.0'


After that an option on my list of my list gradle task appears like ="buildWSDD". However, after launch this task the jar is not being generating... I only see a server-config.wsdd in my project.

The exist of the execution of gradle task is:

:modules:devshaker:devshaker-service:buildWSDD
  Java2WSDL com.devshaker.service.http.ApiServiceSoap
  WSDL2Java C:\Users\je10413\AppData\Local\Temp\3830720253605649888/service.wsdl
  Deleting directory C:\Users\je10413\AppData\Local\Temp\3830720253605649888

BUILD SUCCESSFUL

Total time: 2.804 secs


Maybe I am missing something.
thumbnail
Javier Gamarra, geändert vor 7 Jahren.

RE: Error generating custom services with builder sdk for android (Antwort)

Expert Beiträge: 348 Beitrittsdatum: 12.02.15 Neueste Beiträge
Do you want to generate the web services for 6.2 or 7.x/DXP? I suppose you want to use 7.x because of the osgi references.

There is not an official release (paging Bruno) for generating 7.x services but it is working in master. In the sdk-builder.gradle comment the code to be similar to this:


//if (project.parent && (project.parent.name == 'liferay-mobile-sdk')) {
		builder project(':builder')
	//}
	//else {
	//	builder group: 'com.liferay.mobile', name: 'liferay-sdk-builder', version: '6.2.0.+'
	//}


To force using the master version instead of downloading the latest 6.2 release. It should work correctly.

If your service is visible from server:port/api/jsonws you don't have to worry about WSDD. It makes sense to use the services instead of retrofit to not have to create manually all the services, deal with special Liferay parameters and lots of small things...
Miguel Pereira, geändert vor 7 Jahren.

RE: Error generating custom services with builder sdk for android

New Member Beiträge: 6 Beitrittsdatum: 26.03.16 Neueste Beiträge
Hello Javier,

Thanks a lot for your reply. This worked for me!