- This topic has 1 reply, 2 voices, and was last updated 17 years, 8 months ago by Riyad Kalla.
-
AuthorPosts
-
Lee HarringtonMemberAs requested byyou, rkrella:
MyEclipse Code-First Web Services Quickstart
http://myeclipseide.com/enterpriseworkbench/help/index.jsp?topic=/com.genuitec.myeclipse.doc/html/quickstarts/webservices/index.html
9.2 Create the HelloWorldClient ClassThe code segment below defines the process for creating an XFire web service proxy that supports the POJO IHelloWorldService interface. Once the proxy has been constructed and cast to the IHelloWorldService it can be used like a standard Java class.
public static void main(String[] args) {
Service srvcModel = new
ObjectServiceFactory().create(IHelloWorldService.class);
XFireProxyFactory factory =
new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String helloWorldURL =
“http://localhost:8080/HelloWorld/services/HelloWorldService”;
try {
IHelloWorldService srvc = (IHelloWorldService)factory.create(srvcModel, helloWorldURL);
String result = srvc.example(“hello world”);
System.out.print(result);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}This code doesn’t work becaus you also need to add the following import statements:
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import java.net.MalformedURLException;————————————————————————
MyEclipse Web Service Client Demo
http://www.myeclipseide.com/images/tutorials/demos/terra_server_client/tutorial.htmlSection 4
code to copy in has the following line:LonLatPt result = terraServiceSoap.convertPlaceToLonLatPt(place);
needs to be changed to:
LonLatPt result = service.convertPlaceToLonLatPt(place);
I also needed to add an import, but I can’t remember what specifically.
————————————————————————-
Hibernate generator. Would be nice if you could generate and then just use the code.
I can’t as specific with the hibernate problems, but I’ll give you what I remember:
1. Adding hibernate via myEclipse does not add the common libs for logging, but the generated hibernate code uses log4j. But as it does so via a factory — the error isn’t at compile time — scratched my head quite a bit over that one.
2. I generated hibernate mappings — and factory — and tried to use the classes to no avail. in this example my table was wstest. Creating a new instance object, setting values, and then calling the service doesn’t work. Maybe not the way I’m supposed to use the classes — having the generator generate a “code to call the code” would help.
WstestDAO wsService = new WstestDAO();
Wstest wsTest = new Wstest();
wsTest.setWsNumber(wsNumber);
wsTest.setWsName(wsName);
wsService.save(wsTest);Just watched the BasicDB — and it’s out of date (well, doesn’t cover hibernate 3.0 anyway) — but I did notice that I hadn’t put in my database specific drivers.
——————————————————————————-
Hope I’ve helped with these opportunities for improvement of the documentation. Love the product. Wish I was smarter so that these little problems wouldn’t cause me to spin my wheels so long 🙂
Lee
Riyad KallaMemberLee,
First let me thank you for putting all this together. I checked back with the guys that worked on the Web Services guide, and after a lot of trouble shooting we figured out the reason they never made a note of the issue, as well as in the screencast I did, of the imports is because of the feature:
Window > Preferences > Java > Editor > Type > “When pasting” > Update importsThis option defaults to On in new workspaces, and when we do demos and put together tutorials, we always use new workspaces which is why we never ran into this issue. As soon as we pasted the imports were updated.
I’ll make a note to update the documentation when those guys get some time from the 5.5 release planning.
Also, I went back and checked the terra server web service code:
LonLatPt result = terraServiceSoap.convertPlaceToLonLatPt(place); needs to be changed to: LonLatPt result = service.convertPlaceToLonLatPt(place);
and the original code is correct, the changed code wouldn’t compile because there is no variable “service”, the one generated is “terraServiceSoap”. Go slowly through the 3rd movie and about 1/2 way through you’ll see it. So I’m not sure what happened here…
-
AuthorPosts