3/4/08


Webogic Web Services invocation

Let's look into some WebLogic WebService:

import javax.jws.*;
@WebServicepublic class ErrWs {
@WebMethod

public void meth1RunTime() {
throw new RuntimeException(" >> RUN TIME EXCEPTION << ");
}

@WebMethod
public void meth2Checked() throws MyException {
throw new MyException(" >> MyException EXCEPTION << ");
}
}

How we can use that web service in java code? First of all use jwsc ant task to genrate JAX-RPC code for that web service:

<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask">
<classpath refid="..." />
</taskdef>

<jwsc srcdir="src" destdir="${somedir-dir}">
<jws file="com/ws/ErrWs.java">
</jws>
</jwsc>

In case of some WebLogic web application we can generate web service control but for standalone application (or non WebLogic web application) we need use ClientGenTask. But there is some strange behaviour I meet with..
Below content of my ant build.xml:

< project
default="wsc_lient_gen"
name="LocalClient">
< path id="wl_cp">
< pathelement path="lib/weblogic.jar">
< pathelement path="lib/xbean.jar">
< pathelement path="lib/apache_xbean.jar">
< pathelement path="lib/webserviceclient.jar">
</path>
<taskdef

name="clientgen"
classpathref="wl_cp"
classname="weblogic.wsee.tools.anttasks.ClientGenTask">
</taskdef >
<target name="wsc_lient_gen">
<clientgen

classpathref="wl_cp"
wsdl=http://localhost:7001/WebService_ws/ErrWs?WSDL
destdir="gen">
</target>
</project>


But there is exception while run that code right in Eclipse environment:

Buildfile: D:\Screwfix\ErrAttempts_java2\Test\build.xml
wsc_lient_gen:
Generating client from http://localhost:7001/WebService_ws/ErrWs?WSDL ...
[clientgen] Package name is com
[clientgen] DestDir is D:\Screwfix\ErrAttempts_java2\Test\gen
[clientgen] class name is ErrWs_Stub
[clientgen] service class name is ErrWsService
[clientgen] Porttype name is ErrWs
[clientgen] service impl name is ErrWsService_Impl
BUILD FAILED
java.lang.AssertionError: java.io.IOException
Total time: 3 seconds


But in CLI, if before invoking set domain environment:

> %SOME_WL_DOMAIN_PATH%\bin\setDomainEnv.cmd
> ant
all artifacts are generated successfully.

After those operation we need some client's code to invoke web service: (and also 4 *.jar in classpath presented in ant's build file)

ErrWsService service = new ErrWsService_Impl();
ErrWs port = service.getErrWsSoapPort();
port.meth1RunTime();

No comments: