Search This Blog

Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Friday, 21 January 2011

Invoking a JAX-WS Oracle Weblogic 11g (10.3.4) Web Service from JRuby

The following demo show how to call a JAX-WS from Oracle Weblogic Server 11g (10.3.4) from a JRuby script. The real work is done by JDeveloper 11g (11.1.1.4) which creates the Web Service, generates a proxy client JAR which JRuby then uses to invoke the Web Service.

So in JDeveloper we have 2 projects one for the Web Service and one for the Proxy.



The Web Service is deployed to Weblogic 10.3.4 as shown below.



1. Create a JRuby script named "jaxws11g.rb" as follows
require 'java'

# the web service client JAR file generated from JDeveloper 11g Proxy wizard
require 'SimpleWSService-Client.jar'

java_import 'pas.au.wsclient.SimpleWSPortClient'

class TestWLSWebService

  def initialize
    @wsclient = SimpleWSPortClient.new  
  end
  
  def invoke_method
    return @wsclient.invoke_method
  end
  
end


print "Run at #{Time.now} using JRuby #{RUBY_VERSION}\n\n"

print "** FMW Weblogic 10.3.4 Web Service Invoke Test **\n\n"

test = TestWLSWebService.new
print test.invoke_method

print "\n\nEnded at #{Time.now} \n"

2. The JAR file referenced below is the Web Service proxy JAR file which is generated by JDeveloper once a proxy project is created from the WSDL file for the Web Service.


# the web service client JAR file generated from JDeveloper 11g Proxy wizard
require 'SimpleWSService-Client.jar'


3. Run shown below which simply identified the Weblogic managed server name it's running in and the date it was invoked.

> jruby jaxws11g.rb


Run at Fri Jan 21 11:10:37 +1100 2011 using JRuby 1.8.7
** FMW Weblogic 10.3.4 Web Service Invoke Test **
SimpleWS invoked at Thu Jan 20 11:05:13 EST 2011 from Weblogic Managed Server named apple
Ended at Fri Jan 21 11:10:38 +1100 2011

The Web Service is a simple class as follows

package pas.au.ws;

import java.util.Date;

import javax.jws.WebService;

@WebService
public class SimpleWS 
{
  public SimpleWS() 
  {
  }
    
  public String getManagedServerName () 
  {
    String retData = 
      String.format("SimpleWS invoked at %s from Weblogic Managed Server named %s", 
                    new Date(),
                    System.getProperty("weblogic.Name"));
    
    return retData;
    
  }
}

Tuesday, 10 August 2010

UTL_DBWS : Handling Web Service methods that accept XML Input parameters

Dealing with Web Services callouts using the UTL_DBWS package requires some thought when calling methods which accept XML data such as "org.w3c.dom.Element". In this example I show how to ensure the XML data within your XML file is correctly escaped prior to sending the request to the Web Service.

An example of UTL_DBWS package can be found on steve's blog here. That shows how to set it up at the database level in 11g.

Lets assume we have a Web Service deployed to OAS 10.1.3.x with a class as follows. Basic method which takes a org.w3c.dom.Element parameter for it's only service method testXML.

package pas.au.xml.ws;

import org.w3c.dom.Element;

public class XMLWebService
{
  public XMLWebService()
  {
  }
  
  public String testXML (Element xmlInput)
  {
    return "success";
  }
}

With UTL_DBWS installed we could simply write a PLSQL block as follows to call out Web Service method and the output clearly shows this works fine.

set serveroutput on size 100000
set linesize 130

declare

  service_ sys.utl_dbws.SERVICE;
  call_ sys.utl_dbws.CALL;
  service_qname sys.utl_dbws.QNAME;
  port_qname sys.utl_dbws.QNAME;
  response sys.XMLTYPE;
  request sys.XMLTYPE;

  inputXML varchar2(300) := null;
  myXML varchar2(100) := 'pas';

begin

  dbms_output.put_line('Calling Web Service http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPor');
  service_qname := sys.utl_dbws.to_qname(null, 'testXMLElement');
  service_      := sys.utl_dbws.create_service(service_qname);
  call_         := sys.utl_dbws.create_call(service_);
  sys.utl_dbws.set_target_endpoint_address(call_, 'http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPort');
  sys.utl_dbws.set_property( call_, 'OPERATION_STYLE', 'document');

  dbms_output.put_line('Preparing request');

  inputXML := '<ns1:testXMLElement xmlns:ns1="http://pas.au.xml.ws/types/"><ns1:xmlInput><pas>'||
              myXML||
              '</pas></ns1:xmlInput>'||
              '</ns1:testXMLElement>';

  request       := sys.XMLTYPE(inputXML);
  response      := sys.utl_dbws.invoke(call_, request);

  dbms_output.put_line('** Soap Response **'||chr(10)||response.getStringVal());

  dbms_output.put_line('Result = '||
        response.extract('//ns0:result/child::text()',
        'xmlns:ns0="http://pas.au.xml.ws/types/"').getstringval());
end;
/
show errors;

Output

SCOTT@linux11gr2> @invoke_xmlws.sql
Calling Web Service http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPor
Preparing request
** Soap Response **
<ns0:testXMLResponseElement xmlns:ns0="http://pas.au.xml.ws/types/">

<ns0:result>success</ns0:result>
</ns0:testXMLResponseElement>

Result = success

PL/SQL procedure successfully completed.

No errors.
SCOTT@linux11gr2>

The problem here is we can't just assume that the data which we pass into theWeb Service method is not a special character which in the XML world would require that it be escaped. The data we passed in our first test was a simple string such as "pas" as shown below.

myXML varchar2(100) := 'pas';

Lets assume we now want to pass data as follows by introducing a & character. The assumption here is we can't control what is passed to the method so it may be a special character which XML won't accept.

myXML varchar2(100) := 'pas&';

The result when running the PLSQL Block now is a runtime exception as follows.

SCOTT@linux11gr2> @invoke_xmlws.sql
Calling Web Service http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPor
Preparing request
declare
*
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00242: invalid use of ampersand ('&') character (use &amp;)
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 310
ORA-06512: at line 29


No errors.
SCOTT@linux11gr2>

In fact if you try this outside of PLSQL / Oracle RDBMS itself, such as a J2SE client you would get a runtime exception as follows. The database error was a lot more useful then this.

java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Unable to get header stream in saveChanges. SOAP exception while trying to externalize: Error parsing envelope: (1, 1) Start of root element expected.. java.io.IOException: SOAP exception while trying to externalize: Error parsing envelope: (1, 1) Start of root element expected.

So the solution around this is to use the package method dbms_xmlgen.CONVERT to convert the XML data into the escaped XML equivalent. So now our SQL is as follows

set serveroutput on size 100000
set linesize 130
call dbms_java.set_output(100000);

declare

  service_ sys.utl_dbws.SERVICE;
  call_ sys.utl_dbws.CALL;
  service_qname sys.utl_dbws.QNAME;
  port_qname sys.utl_dbws.QNAME;
  response sys.XMLTYPE;
  request sys.XMLTYPE;

  inputXML varchar2(300) := null;
  myXML varchar2(100) := 'pas&';

begin

  dbms_output.put_line('Calling Web Service http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPor');
  service_qname := sys.utl_dbws.to_qname(null, 'testXMLElement');
  service_      := sys.utl_dbws.create_service(service_qname);
  call_         := sys.utl_dbws.create_call(service_);
  sys.utl_dbws.set_target_endpoint_address(call_, 'http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPort');
  sys.utl_dbws.set_property( call_, 'OPERATION_STYLE', 'document');

  dbms_output.put_line('Preparing request');

  --add to convert XML with special characters correctly escaped
  inputXML := '<ns1:testXMLElement xmlns:ns1="http://pas.au.xml.ws/types/"><ns1:xmlInput><pas>'||
              dbms_xmlgen.CONVERT(myXML, dbms_xmlgen.ENTITY_ENCODE)||
              '</pas></ns1:xmlInput>'||
              '</ns1:testXMLElement>';

  request       := sys.XMLTYPE(inputXML);
  response      := sys.utl_dbws.invoke(call_, request);

  dbms_output.put_line('** Soap Response **'||chr(10)||response.getStringVal());

  dbms_output.put_line('Result = '||
         response.extract('//ns0:result/child::text()',
          'xmlns:ns0="http://pas.au.xml.ws/types/"').getstringval());
end;
/
show errors;

Note: I added a call to call dbms_java.set_output(100000); prior to running the BLOCK so we could see our REQUEST/RESPONSE XML to verify it has done what we needed it to do.

And the output now shows it works correctly.

Output

SCOTT@linux11gr2> @invoke_xmlws2.sql

Call completed.

Calling Web Service http://beast.au.oracle.com:7777/xmlws/XMLWSSoapHttpPor
ServiceFacotory: oracle.j2ee.ws.client.ServiceFactoryImpl@7e6efb86
WSDL: null
Service: oracle.j2ee.ws.client.BasicService@917ab4b8
*** Created service: -1261915451 - oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@eec8c59c ***
ServiceProxy.get(-1261915451) = oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@eec8c59c
setProperty(javax.xml.rpc.soap.operation.style, document)
Preparing request
dbwsproxy.add.map: ns1, http://pas.au.xml.ws/types/
Attribute 0: http://pas.au.xml.ws/types/: xmlns:ns1, http://pas.au.xml.ws/types/
dbwsproxy.lookup.map: ns1, http://pas.au.xml.ws/types/
createElement(ns1:testXMLElement,null,http://pas.au.xml.ws/types/)
dbwsproxy.add.soap.element.namespace: ns1, http://pas.au.xml.ws/types/
Attribute 0: http://pas.au.xml.ws/types/: xmlns:ns1, http://pas.au.xml.ws/types/
dbwsproxy.element.node.child.0: 1, null
dbwsproxy.lookup.map: ns1, http://pas.au.xml.ws/types/
createElement(ns1:xmlInput,null,http://pas.au.xml.ws/types/)
dbwsproxy.element.node.child.0: 1, null
createElement(pas,null,null)
dbwsproxy.text.node.child.0: 3, pas&
request:
<ns1:testXMLElement xmlns:ns1="http://pas.au.xml.ws/types/">
<ns1:xmlInput>
<pas>pas&amp;</pas>
</ns1:xmlInput>
</ns1:testXMLElement>
response:
<ns0:testXMLResponseElement xmlns:ns0="http://pas.au.xml.ws/types/">
<ns0:result>success</ns0:result>
</ns0:testXMLResponseElement>
** Soap Response **
<ns0:testXMLResponseElement xmlns:ns0="http://pas.au.xml.ws/types/">

<ns0:result>success</ns0:result>
</ns0:testXMLResponseElement>

Result = success

PL/SQL procedure successfully completed.

No errors.
SCOTT@linux11gr2>

Thursday, 24 September 2009

Trace/Diagnostics output from ADF BC Web Services using FMC (EM) in OFM 11g R1

When you deploy your ADF BC Application module as a Web Service interface you can take advantage of Fusion Middleware Contol (EM) to trace the web service execution from FMC (EM) itself as I will show here.

Note: This is only applicable to ADF BC Web Services, the same steps won't work for JAX-WS or PLSQL web services created in JDeveloper 11g R1.

The documentation for Service-Enabled application modules can be found here.

Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework
11g Release 1 (11.1.1)

Part Number B31974-03
11 Integrating Service-Enabled Application Modules
http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcextservices.htm#CJAJGIEB

In order to do this we need to achieve 3 steps here.

1. Setup Fusion Middleware Control (EM) in your domain

In short your domain will need to be setup as per these steps.

http://theblasfrompas.blogspot.com/2009/07/installing-adf-runtime-on-oracle-fusion.html

2. Deploy an ADF BC App Module as a Web Service Interface

Note: It is assumed you have a client method exposed in your ADF BC application module. An example of such a method is as follows. You will need to ensure the method is exposed as a client method.


public String getVersion ()
{
return getSession().getVersion();
}

2.1. Right click on your application module XML file and and select "Open {app module name}"
2.2. Select "Service Interface"
2.3. Select the + symbol
2.4. Enter in the service interface details.
2.5. Click next
2.6. Shuttle across the methods you wish to expose.
2.7. Ignore the "Service View Instances" and click next
2.8 Click Finish.

You end up with something as follows in the application navigator.





















2.9. Now we need to create a deployment profile which we do by double clicking on the proejct to invoke the "Project properties" dialog.
2.10. Select "deployment"
2.11. Click New
2.12. Select the archive type as "Business Components service Interface"

2.13. Give it a name and press Ok

At this point you have created an EJB JAR file , which you can deploy by using the menu item for the workspace "Deploy" and targeting an Application Server Connection for your OFM 11g R1 server. Once deployed you should end up with output as follows.

[10:38:37 AM] ---- Deployment started. ----
[10:38:37 AM] Target platform is (Weblogic 10.3).
[10:38:44 AM] Entering Target Selection Dialog
[10:38:48 AM] Retrieving existing application information
[10:38:48 AM] Running dependency analysis...
[10:38:48 AM] Building...
[10:38:49 AM] Deploying 3 profiles...
[10:38:49 AM] Wrote EJB Module to D:\jdev11gr1\jdeveloper\jdev\mywork\ADFBC-WS\Demo\deploy\ADFBC-WS-Demo-context-root.jar
[10:38:50 AM] Wrote Archive Module to D:\jdev11gr1\jdeveloper\jdev\mywork\ADFBC-WS\Demo\deploy\adfbc-ws_Common.jar
[10:38:50 AM] Wrote Enterprise Application Module to D:\jdev11gr1\jdeveloper\jdev\mywork\ADFBC-WS\deploy\Demo_adfbc-ws.ear
[10:38:52 AM] INFO: Unable to load annotation weblogic.javaee.CallByReferencefor parsing. The annotation is ignored.
[10:38:52 AM] INFO: Unable to load annotation weblogic.javaee.CallByReferencefor parsing. The annotation is ignored.
[10:38:52 AM] INFO: GenericWSWarAnnotationListener.parseAnnotatedClass Adding Servlet Mapping with URL pattern /AppModuleService for annotated WebService class pas.au.adf.ws.server.serviceinterface.AppModuleServiceImpl
[10:38:54 AM] Deploying Application...
[10:38:59 AM] [Deployer:149191]Operation 'deploy' on application 'Demo_adfbc-ws' is initializing on 'debug_ws'
[10:39:16 AM] [Deployer:149192]Operation 'deploy' on application 'Demo_adfbc-ws' is in progress on 'debug_ws'
[10:39:21 AM] [Deployer:149194]Operation 'deploy' on application 'Demo_adfbc-ws' has succeeded on 'debug_ws'
[10:39:21 AM] Application Deployed Successfully.
[10:39:21 AM] Elapsed time for deployment: 43 seconds
[10:39:21 AM] ---- Deployment finished. ----


3. Use FMC (EM) to trace the ADF BC web service execution.


3.1 Log into FMC (EM) as follows

http://{server}:{port}/em

3.2 In the navigator pane, expand WebLogic Domain
3.3. Expand the domain
3.4. Select the desired server from the list.
3.5. From the WebLogic Sever menu, select Logs > Log Configuration
3.6. On the "Log Levels" tab you need to select "Loggers with persistent Log Level State", then expand the "Specify Loggers"
3.7. At the bottom and enter the logger name "oracle.webservices" and optionally setup the "
Diagnostic Logging Level" you wish to use.
3.8. Press Apply.

Now at this point we have to restart the server.

Once re-started log back into EM and verify the Log configuration shows "oracle.webservices" as shown below.














Now we can test our web services as shown in this entry and verify we get web services diagnostics logging placed into the log file "debug_ws-diagnostic.log" which would be in a directory as follows $DOMAIN_HOME/servers/{managed-server-name}/logs

http://theblasfrompas.blogspot.com/2009/09/web-services-security-in-ofm-11g-r1.html

An example of the output is as follows


<anonymous>
] [ecid: 0000IFdFy2wFw000jzwkno1Aidcd00003S,0:3] [WEBSERVICE_PORT.name:
AppModuleServiceSoapHttpPort] [APP: Demo_adfbc-ws] [J2EE_MODULE.name:
ADFBC-WS-Demo-context-root] [WEBSERVICE.name: AppModuleService]
[J2EE_APP.name: Demo_adfbc-ws] Incomplete connection information
[2009-09-24T09:32:46.827+10:00] [debug_ws] [WARNING] []
[oracle.adf.share.jndi.ReferenceStoreHelper] [tid: [ACTIVE].ExecuteThread:
'2' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId:
<anonymous>
] [ecid: 0000IFdFy2wFw000jzwkno1Aidcd00003S,0:3] [WEBSERVICE_PORT.name:
AppModuleServiceSoapHttpPort] [APP: Demo_adfbc-ws] [J2EE_MODULE.name:
ADFBC-WS-Demo-context-root] [WEBSERVICE.name: AppModuleService]
[J2EE_APP.name: Demo_adfbc-ws] Incomplete connection reference object
[2009-09-24T09:32:50.828+10:00] [debug_ws] [TRACE] [OWS-04010]
[oracle.webservices.service] [tid: [ACTIVE].ExecuteThread: '2' for queue:
'weblogic.kernel.Default (self-tuning)'] [userId:
<anonymous>
] [ecid: 0000IFdFy2wFw000jzwkno1Aidcd00003S,0:3] [SRC_CLASS:
oracle.j2ee.ws.server.ServerMessages] [APP: Demo_adfbc-ws] [SRC_METHOD:
fineMsgServletResponse] [arg:
{/pas/au/adf/ws/common/}AppModuleServiceSoapHttpPort] [arg:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns0:getVersionResponse xmlns:ns0="/pas/au/adf/ws/common/types/">
<result xmlns="/pas/au/adf/ws/common/types/">11.1.1.54.7</result>
</ns0:getVersionResponse>
</env:Body>
</env:Envelope>
] The SOAP response for port:
{/pas/au/adf/ws/common/}AppModuleServiceSoapHttpPort is:[[

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns0:getVersionResponse xmlns:ns0="/pas/au/adf/ws/common/types/">
<result xmlns="/pas/au/adf/ws/common/types/">11.1.1.54.7</result>
</ns0:getVersionResponse>
</env:Body>
</env:Envelope>
]]
</anonymous>
</anonymous>
</anonymous>

You can also view the log file from FMC (EM) as follows
:

- From the WebLogic Sever menu, select Logs > View Log Messages
- Click on "Target Log Files" button.
- In the log files table select the row containing "debug_ws-diagnostic.log" and press the button "View Log File".

More Information

Oracle® Fusion Middleware Security and Administrator's Guide for Web Services
11g Release 1 (11.1.1)
Part Number B32511-01
15 Diagnosing Problems
http://download.oracle.com/docs/cd/E12839_01/web.1111/b32511/diagnosing.htm#WSSEC1226

Monday, 14 September 2009

Web Services Security in OFM 11g R1

I ran 2 good blog entries for securing web services from JDeveloper 11g onto WLS 11g R1. Both these are great starting points for that and worked well. Saves a lot of time when it's all laid out step by step.

http://one-size-doesnt-fit-all.blogspot.com/2009/08/one-way-ssl-with-jax-ws-using.html

http://kingsfleet.blogspot.com/2009/01/security-policy-worked-example.html

I always create my WLS domains adding Fusion Middleware Control and that then gives you the ability to test the web service from a browser as well as view some runtime statistics for the web service itself when logging into the "/em" application installed into the admin server.

The blog entry showing how to install Fusion Middleware Control into a WLS 11g R1 domain is as follows. I even started deploying from that application rather then using the traditional console application.

http://theblasfrompas.blogspot.com/2009/07/installing-adf-runtime-on-oracle-fusion.html

So in short

1. Log into em using an url as follows

http://{server}:{adminserverport}/em

2. Click on your web service application
3. If indeed web services exist in the application you will see a web services table and "Java EE Web Services" tab as shown below.














4. Click on the "Test" icon to test your web service.

Tuesday, 1 September 2009

JDeveloper 11g - PLSQL Web Service Returning a Table of Objects

Got a few emails about problems using a Table of Objects within PLSQL Web Services now it's been reintroduced into JDeveloper 11g. Here is a small demo which worked fine for me.

1. Run the following SQL in the classic SCOTT schema

drop type dept_type;
drop type dept_list_table;

create type dept_type as object
(deptno NUMBER,
dname VARCHAR2(14),
loc varchar2(13),
cr_date date)
/

create type dept_list_table is table of dept_type
/

purge recyclebin;

create or replace package ws_package as

function test_dept_table return dept_list_table;

end ws_package;
/
show errors;

create or replace package body ws_package as

function test_dept_table return dept_list_table is

all_depts dept_list_table := dept_list_table();
dRecType dept_type;
i number := 0;

begin

-- iterate through all depts
for r_list in (select * from dept) loop

i := i + 1;

dRecType := dept_type(null, null, null, null);
dRecType.deptno := r_list.deptno;
dRecType.dname := r_list.dname;
dRecType.loc := r_list.loc;
dRecType.cr_date := sysdate;

all_depts.extend;
all_depts(i) := dRecType;

end loop;

return all_depts;

end test_dept_table;

end ws_package;
/
show errors;
2. Create a PLSQL Web Service called "DemoWS" using the defaults for the package WS_PACKAGE.

3. Right click on the Web Service "DemoWS" and select "Run". It may take a while to start but eventually you should see it's started as follows.

Run startup time: 10437 ms.
[Application WebServicesTest deployed to Server Instance DefaultServer]

Target URL -- http://localhost:7101/WebServicesTest-PLSQLTest-context-root/DemoWSPort
09/08/13 09:49:19 Web service DemoWS has been started on the embedded server

4. Copy the URL above into a browser.
5. Click on "Test Page"
6. Click on the only function "testDeptTable"
7. Verify response as follows.

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header />
<env:Body>
<m:testDeptTableResponse xmlns:m="http://au/support/ws/DemoWS.wsdl">
<result xmlns:typ="http://au/support/ws/DemoWS.wsdl/types/">
<typ:DeptTypeUser>
<typ:dname>ACCOUNTING</typ:dname>
<typ:loc>NEW YORK</typ:loc>
<typ:deptno>10</typ:deptno>
<typ:crDate>2009-08-13T08:36:53.000+10:00</typ:crDate>
</typ:DeptTypeUser>
<typ:DeptTypeUser>
<typ:dname>RESEARCH</typ:dname>
<typ:loc>DALLAS</typ:loc>
<typ:deptno>20</typ:deptno>
<typ:crDate>2009-08-13T08:36:53.000+10:00</typ:crDate>
</typ:DeptTypeUser>
<typ:DeptTypeUser>
<typ:dname>SALES</typ:dname>
<typ:loc>CHICAGO</typ:loc>
<typ:deptno>30</typ:deptno>
<typ:crDate>2009-08-13T08:36:53.000+10:00</typ:crDate>
</typ:DeptTypeUser>
<typ:DeptTypeUser>
<typ:dname>OPERATIONS</typ:dname>
<typ:loc>BOSTON</typ:loc>
<typ:deptno>40</typ:deptno>
<typ:crDate>2009-08-13T08:36:53.000+10:00</typ:crDate>
</typ:DeptTypeUser>
</result>
</m:testDeptTableResponse>
</env:Body>
</env:Envelope>

Note: If you wanted to test using the Table as an IN parameter simply create a method as follows in the PLSQL package which would enable you to test this as well.

function echo_dept_list_table (v1 in dept_list_table) return dept_list_table is

begin

return v1;

end echo_dept_list_table;

Tuesday, 17 March 2009

Getting debug output from utl_dbws PLSQL package

When calling web services from an oracle database you can use utl_dbws package. There are times though that you need to debug it to determine why it may be failing. This can be achieved as follows.

call dbms_java.set_output(100000);

Example output from a SQL file as follows. This example is calling a JAXRPC 1.4 web service from OAS 10.1.3.4

SQL:

set serveroutput on

call dbms_java.set_output(100000);

-- call web service methods here now for end point below
-- http://beast.au.oracle.com:7777/wsrocks/DemoWSSoapHttpPort
-- WSDL = http://beast.au.oracle.com:7777/wsrocks/DemoWSSoapHttpPort?WSDL

prompt
prompt Calling method todaysDate from web service
prompt

select PasWS102.todaysDate from dual;

prompt
prompt Calling method echoString from web service
prompt

select PasWS102.echoString('Pas') from dual;

Output:


SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 17 08:56:38 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Enter password: *****

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Call completed.

Calling method todaysDate from web service


TODAYSDATE
----------------------------------------------------------------------------------------------------
Tue Mar 17 07:57:37 EST 2009

ServiceFacotory: oracle.j2ee.ws.client.ServiceFactoryImpl@bb101899
WSDL: null
Service: oracle.j2ee.ws.client.BasicService@ce6cb3d5
*** Created service: -677524827 - oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@2968f5e4 ***
ServiceProxy.get(-677524827) = oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@2968f5e4
** Calling web service method {todaysDate} **
setProperty(javax.xml.rpc.soap.http.soapaction.use, true)
setProperty(javax.xml.rpc.soap.http.soapaction.uri, http://pas.au.ws//todaysDate)
setProperty(javax.xml.rpc.soap.operation.style, document)
** Invoking web service method {todaysDate} **
Attribute 0: http://pas.au.ws/types/: xmlns, http://pas.au.ws/types/
createElement(todaysDateElement,null,http://pas.au.ws/types/)
Attribute 0: http://pas.au.ws/types/: xmlns, http://pas.au.ws/types/
request:

response:

Tue Mar 17 07:57:37 EST 2009

** Successfully invoked web service method {todaysDate} **

Calling method echoString from web service


PASWS102.ECHOSTRING('PAS')
----------------------------------------------------------------------------------------------------
Pas

ServiceFacotory: oracle.j2ee.ws.client.ServiceFactoryImpl@bb101899
WSDL: null
Service: oracle.j2ee.ws.client.BasicService@d05260ad
*** Created service: -677524826 - oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@7789dbfd ***
ServiceProxy.get(-677524826) = oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@7789dbfd
** Calling web service method {echoString} **
setProperty(javax.xml.rpc.soap.http.soapaction.use, true)
setProperty(javax.xml.rpc.soap.http.soapaction.uri, http://pas.au.ws//echoString)
setProperty(javax.xml.rpc.soap.operation.style, document)
** Invoking web service method {echoString} **
Attribute 0: http://pas.au.ws/types/: xmlns, http://pas.au.ws/types/
createElement(echoStringElement,null,http://pas.au.ws/types/)
Attribute 0: http://pas.au.ws/types/: xmlns, http://pas.au.ws/types/
dbwsproxy.element.node.child.0: 1, null
createElement(s,null,http://pas.au.ws/types/)
dbwsproxy.text.node.child.0: 3, Pas
request:

Pas

response:

Pas

** Successfully invoked web service method {echoString} **
SCOTT@linux10g>

Friday, 18 July 2008

Having JDeveloper 10.1.3.x on your PC

If you have JDeveloper 10.1.3.x on your file system you can take advantage of 2 JAR files even without actually using the IDE. There useful utilities if your using OAS 10.1.3.x. Those are as follows.

$JDEV_HOME\j2ee\home\admin_client.jar - OC4J provides a command-line utility, admin_client.jar, for performing configuration, administration, and deployment tasks on active OC4J instances in an Oracle Application Server clustered environment as well as on a standalone OC4J server. In addition, you can use admin_client.jar to restart or stop an OC4J instance or group of instances. See this document for more details.

Oracle® Containers for J2EE Configuration and Administration Guide
10g (10.1.3.1.0)
Part Number B28950-01
http://download-uk.oracle.com/docs/cd/B31017_01/web.1013/b28950/adminclient.htm#BABCCJEC

$JDEV_HOME\webservices\lib\wsa.jar - The WebServicesAssembler tool assists in assembling Oracle Application Server Web Services. It enables you to generate the artifacts required to develop and deploy Web services, regardless of whether you are creating the service top down or bottom up. The WebServicesAssembler can also be invoked to create Web service client objects based on a WSDL. See this document for more details.

Oracle® Application Server Web Services Developer's Guide
10g (10.1.3.1.0)
Part Number B28974-01
http://download-uk.oracle.com/docs/cd/B31017_01/web.1013/b28974/wsassemble.htm#CHDDBCCA

For both of these utilties use the -help option for more details of what command line options can be used.

Eg:

> java -jar D:\jdev\jdevprod\10133\webservices\lib\wsa.jar -help

Note: Stand Alone OC4J has the same JAR files as well.