Quantcast
Channel: DevOps tips & tricks
Viewing all articles
Browse latest Browse all 181

Weblogic 12.2.1 - build webservice using jwsc Ant task

$
0
0
We want to test Ant jwsc task on Weblogic 12.2.1 server 

This blog is used to start project
https://www.igorkromin.net/index.php/2015/04/28/an-example-build-system-using-jwsc-and-wldeploy-weblogic-tasks/

Another blog https://gerardnico.com/wiki/weblogic/web_service

Weblogic documetation for  weblogic.wsee.tools.anttasks.JwscTask
 http://docs.oracle.com/middleware/1221/wls/WSGET/jax-ws-setenv.htm#WSGET136


Project structure

dave@localhost jwsc-ant-webservice]$ ls -R1
.:
build
build-base.xml
build.properties
build.xml
dist
lib
src

./build:
META-INF
WsExample.war

./build/META-INF:
application.xml
weblogic-application.xml

./dist:
WsExample.ear

./lib:

./src:
org

./src/org:
dave

./src/org/dave:
SayHello.java


Webservice source code  ( from Weblogic Maven  sample ) - see here http://danielveselka.blogspot.cz/2017/09/weblogic-122-1-implement-webservice.html

[dave@localhost jwsc-ant-webservice]$ more ../dave-basic-webservice-project/src/main/java/org/dave/SayHello.java 
package org.dave;

// Import the standard JWS annotation interfaces

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

// Standard JWS annotation that specifies that the name of the Web Service is
// "Simple" and the targetNamespace used in the generated WSDL is
// "http://example.org"
@WebService(name="SayHello", targetNamespace="http://example.org", serviceName = "SayHello")

// Standard JWS annotation that specifies the mapping of the service onto the
// SOAP message protocol.
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,
             use=SOAPBinding.Use.LITERAL,
             parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)

/**
 * This JWS file forms the basis of a simple WebLogic Web Service with a
 * single operation: sayHello
 *
 * @author Copyright (c) 1999,2013, Oracle and/or its affiliates. All rights reserved.
 */

public class SayHello {

  // Required constructor

  public SayHello() {}

  // Standard JWS annotation that specifies that the method should be exposed
  // as a public operation.  Because the annotation does not include the
  // member-value "operationName", the public name of the operation is the
  // same as the method name: sayHello.

  @WebMethod()
  public String sayHello(String message) {
    System.out.println("sayHello:" + message);
    return "Here is the message: '" + message + "'";
  }
}

Compilation requires multiple jars or Weblogic installation reference in libs.dir

[dave@localhost jwsc-ant-webservice]$ more build.properties 
# WLS details
wls.adminurl=t3://localhost:7001
wls.targets=AdminServer
wls.user=weblogic
wls.passwd=SOME_PASSWORD
# Directories
libs.dir=/app/weblogic-12.2.1/wlserver/server/lib
build.dir=build
dist.dir=dist
src.dir=src
# WS details
ws.name=WsExample
ws.context=wsexample
ws.jwsfile=org/dave/SayHello.java
ws.keepgenerated=yes


Deploy webservice

[dave@localhost jwsc-ant-webservice]$ ant -p
Buildfile: /home/dave/git/weblogic/jwsc-ant-webservice/build.xml

Main targets:

Other targets:

 all
 build-fail
 build-service
 clean
 deploy-service
 init
Default target: all
[dave@localhost jwsc-ant-webservice]$ ant deploy-service
Buildfile: /home/dave/git/weblogic/jwsc-ant-webservice/build.xml

init:

build-service:
     [jwsc] warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
     [jwsc] JWS: processing module WsExample
     [jwsc] Parsing source files
     [jwsc] Parsing source files
     [jwsc] 1 JWS files being processed for module WsExample
     [jwsc] JWS: /home/dave/git/weblogic/jwsc-ant-webservice/src/org/dave/SayHello.java Validated.
     [jwsc] Processing 1 JAX-WS web services...
     [jwsc] Compiling 3 source files to /tmp/_9ddhhq
     [jwsc] Deleting existing module outputFile /home/dave/git/weblogic/jwsc-ant-webservice/build/WsExample.war
     [jwsc] Building jar: /home/dave/git/weblogic/jwsc-ant-webservice/build/WsExample.war
     [jwsc] Created JWS deployment outputFile: /home/dave/git/weblogic/jwsc-ant-webservice/build/WsExample.war
     [jwsc] [EarFile] Application File : /home/dave/git/weblogic/jwsc-ant-webservice/build/META-INF/application.xml
[AntUtil.deleteDir] Deleting directory /tmp/_9ddhhq
      [ear] Building ear: /home/dave/git/weblogic/jwsc-ant-webservice/dist/WsExample.ear

deploy-service:
 [wldeploy] weblogic.Deployer -noexit -name WsExample -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -password ******** -undeploy
 [wldeploy] weblogic.Deployer invoked with options:  -noexit -name WsExample -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -undeploy
 [wldeploy] <Sep 17, 2017 12:46:48 PM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating undeploy operation for application, WsExample [archive: null], to AdminServer .>



Test webservice using  http://localhost:7001/wsexample/SayHello


Endpoint     Information
Service Name:    {http://example.org}SayHello
Port Name:    {http://example.org}SayHelloPort
   
Address:    http://localhost:7001/wsexample/SayHello
WSDL:    http://localhost:7001/wsexample/SayHello?wsdlTest
Implementation class:    org.dave.SayHello


WSDL  http://localhost:7001/wsexample/SayHello?wsdl

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.11-b150616.1732 svn-revision#a247ba216861f2c0baac9a3657c5690bce0c744d. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.11-b150616.1732 svn-revision#a247ba216861f2c0baac9a3657c5690bce0c744d. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://example.org" name="SayHello">
<types>
<xsd:schema>
<xsd:import namespace="http://example.org" schemaLocation="http://localhost:7001/wsexample/SayHello?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="SayHello">
<operation name="sayHello">
<input wsam:Action="http://example.org/SayHello/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="http://example.org/SayHello/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="SayHelloPortBinding" type="tns:SayHello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="SayHello">
<port name="SayHelloPort" binding="tns:SayHelloPortBinding">
<soap:address location="http://localhost:7001/wsexample/SayHello"/>
</port>
</service>
</definitions>

Test result:

request
    request-1505645963920

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body>
        <ns1:sayHello xmlns:ns1="http://example.org">
            <arg0>dave</arg0>
        </ns1:sayHello>
    </soap:Body>
</soap:Envelope>



response:

    response-1505645964157

<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns0:sayHelloResponse xmlns:ns0="http://example.org">
            <return>Here is the message: 'dave'</return>
        </ns0:sayHelloResponse>
    </S:Body>
</S:Envelope>






Viewing all articles
Browse latest Browse all 181

Trending Articles