Developing Webservice from PL/SQL package
Oracle 10.2.0.1.0
Oracle JDeveloper 10.1.3.1.0
Oracle APEX 3.2
Oracle HTTP server w/ mod_plsql
Hello! I'm not sure if this is the right forum for this post, if not please direct me to the more appropriate forum...
I have a need to create a webservice for packaged procs in our database. The purpose is to allow other systems to be able to utilize this webservice in order to pass information to our Oracle APEX application. I have attempted to follow the example provided in the following link:
http://st-curriculum.oracle.com/obe/jdev/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm
However, being new to webservices, I'm having trouble understanding what needs to be done in order to publish the webservice. I'm not sure what steps our DBA needs to perform in order to install and configure OC4J. Any suggestions or references on how to get started with this?
Your help and guidance is appreciated!
-- Chirayu
You need to have an instance of OC4J running on a server. Then you can deploy to it directly from insider JDeveloper.
A basic how-to that show deployment with 10.1.3 is here:
http://www.oracle.com/technetwork/testcontent/deployment-100609.html
The Oracle Application Server documentation library will have instructions about installing OC4J on the server and configuring it.
Similar Messages
-
Creating a webservice from PL/SQL Package in JDev 11g
Hi All...
I have a PL/SQl package and I am using JDEv 11g. I want to create it as a webservice. I want to deploy it in a remote server. Can I deploy it from my client machine. In server Weblogic already started. What are the prerequisites, that we need to deploy a wbservice. I done the following steps.
1. Create an application.
2. Right click the package and select Generate Java option.
3. It create a Java class in the Application sources.
4. Double click the class and select Create Web Service. It created the web service.
5. When I select the webservice and click Run it shows the following error. It going to the Default \server. Actually I need it in a remote server.
[Running application NewWebService on Server Instance DefaultServer...]
---- Deployment started. ---- Apr 20, 2009 1:15:40 PM
Target platform is (Weblogic 10.3).
Running dependency analysis...
2009-04-20 13:15:40.205: Writing WAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService\NewWebService-LastNoWebService-webapp
2009-04-20 13:15:40.222: Wrote WAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService\NewWebService-LastNoWebService-webapp
2009-04-20 13:15:40.357: Writing EAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService
2009-04-20 13:15:40.374: Wrote EAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService
Deploying Application...
<Apr 20, 2009 1:15:40 PM IST> <Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application NewWebService is not versioned.>
<Apr 20, 2009 1:15:40 PM IST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1240213540593' for task '3'. Error is: 'java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext'
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
>
<Apr 20, 2009 1:15:40 PM IST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'NewWebService'.>
<Apr 20, 2009 1:15:40 PM IST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
>
[Deployer:149034]An exception occurred for task [Deployer:149026]deploy application NewWebService on DefaultServer.: sqlj.runtime.ref.DefaultContext.
weblogic.application.WrappedDeploymentException: sqlj.runtime.ref.DefaultContext
#### Deployment incomplete. #### Apr 20, 2009 1:15:40 PM
oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:247)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:157)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:436)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
at oracle.jdevimpl.runner.adrs.AdrsStarter$5$1.run(AdrsStarter.java:1365)
Caused by: oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:413)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:238)
... 11 more
Caused by: oracle.jdeveloper.deploy.DeployException: Deployment Failed
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:395)
... 12 more
#### Cannot run application NewWebService due to error deploying to DefaultServer.
[Application NewWebService stopped and undeployed from Server Instance DefaultServer]
6. when i goto the consoleof weblogic server, already an instance created. But nothing displayed under WebServices.
7. Select the instance and press 'Start'. While deploying an error came.
java.lang.Exception: [DeploymentService:290049]Deploy failed for id '1,240,213,727,265' since no targets are reachable.
Please help me..
its very urgent...
Regards,
Resmi.Oh, no - another very urgent question. The world must be about to end ;)
Resmi, Have a read of [url http://forums.oracle.com/forums/thread.jspa?threadID=883293]this - JDeveloper 11g, as of today, doesn't (at least is not supposed to) support publishing PL/SQL procedures/packages as a web service.
John -
How to generate WebServices for PL/SQL Packages
I have the following issue trying to generate WS for a selected set of operations within a PL/SQL package
If I use the option -sql PKG_TEST then I am getting all operations within a package.
I just want to expose a certain number of procedures ( e.g. PROC1 and PROC2 )
It works only if I specify
-sql PKG_TEST(PROC1)
when I use -sql PKG_TEST(PROC1, PROC2) it gives me errors.
I have Oracle JDeveloper (10.1.3.2) (Build 4066) .
I used wsa with an plsqlAssemble option
java -jar wsa.jar -plsqlAssemble
-appName myApp
-packageName myPckg
-sql PKG_TEST(PROC1)
-dataSource jdbc/ds
-dbConnection jdbc:oracle:thin:@zzzz:1521:mydb -dbUser user/passw
-style rpc
-use literal
Thanks,
Michael HitrikEric,
Thanks a lot for your help.
I was able to follow all of your recommendations
I was able to produce the single ear file for multiple PL/SQL packages .
Now I have the last step ( I hope :-) - WS-SECURITY
What is your recomendation for Security - specifically for WebServices for PL/SQL Packages ?
I would like to do the following:
CLIENT CODE:
* Create a XML element with user name, password, &
* datasource as child elements.
* Element will look like this:
* <credetials>
* <username>scott</username>
* <password>tiger</password>
* <datasource>jdbc/OracleCoreDS</datasource>
* </credentials>
Document doc = new XMLDocument();
Element elAdd = doc.createElement( "credentials");
Element elA = doc.createElement( "username");
Element elB = doc.createElement("password");
Element elC = doc.createElement("datasource");
elA.appendChild(doc.createTextNode("scott"));
elB.appendChild(doc.createTextNode("tiger"));
elC.appendChild(doc.createTextNode("jdbc/OracleCoreDS"));;
elAdd.appendChild(elA);
elAdd.appendChild(elB);
elAdd.appendChild(elC);
doc.appendChild(elAdd);
Element e = doc.getDocumentElement();
// Create an intance of the proxy
EmployeeProxy proxy = new EmployeeProxy();
// Create a Header objecy
Vector v = new Vector();
v.add (e);
Header hdr = new Header();
hdr.setHeaderEntries(v);
// Set the Header
proxy._setSOAPRequestHeaders(hdr);
SERVER CODE:
public void processHeaders(Header header)
throws java.io.IOException,
oracle.xml.parser.v2.XSLException
// Get all the Elements
Vector entries = header.getHeaderEntries();
Element e = (Element) entries.firstElement();
System.out.println("Element received from SOAP header is: " );
((XMLElement)e).print(System.out);
// Get independent nodes and retrieve node values.
Node userNode;
userNode = ((XMLNode)e).selectSingleNode("username");
userName = ((XMLElement)userNode).getText();
Node passwordNode;
passwordNode = ((XMLNode)e).selectSingleNode("password");
password = ((XMLElement)passwordNode).getText();
Node dsNode;
dsNode = ((XMLNode)e).selectSingleNode("datasource");
datasourceName = ((XMLElement)dsNode).getText();
System.out.println("User name is: " + userName);
System.out.println("Password is: " + password);
System.out.println("Datasource is: " + datasourceName);
How can this be done with the generated code using wsa tool ?
Any other suggestions ?
Thanks,
Michael -
Invoking Web Service From PL SQL package
Below is the sample code to invoke web service from pl/sql package using UTL_HTTP:
Declare
http_req UTL_HTTP.req;
http_resp UTL_HTTP.resp;
Begin
http_req :=
UTL_HTTP.begin_request
'http://'
|| lv_hosturl
-- || '.net/soa-infra/services/finance_rt/Payments/paymentsprocess_client_ep',
--new url
|| '.net/soa-infra/services/finance_rt/PaymentsReq/paymentsprocess_client_ep?WSDL',
'POST',
'HTTP/1.1'
UTL_HTTP.set_header (http_req, 'Content-Type', 'text/xml');
-- since we are dealing with plain text in XML documents
UTL_HTTP.set_header (http_req,
'Content-Length',
LENGTH (lv_soap_request)
UTL_HTTP.set_header (http_req, 'SOAPAction', '');
-- required to specify this is a SOAP communication
UTL_HTTP.write_text (http_req, lv_soap_request);
http_resp := UTL_HTTP.get_response (http_req);
UTL_HTTP.read_text (http_resp, lv_soap_respond);
UTL_HTTP.end_response (http_resp);
resp := XMLTYPE.createxml (lv_soap_respond);
End;Hi,
there are a lot of option to make plsql web services .
First you can stay with jdev 10.1.3
Use the xmldb servlets
use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
thanks Edwin -
Support for Creating Web Service from pl/sql package in JDeveloper 11
We have been creating all of our web services from pl/sql packages in our Oracle database using JDeveloper 10.1.3.1. I understand that this capability is not supported in Jdev 11. We have been mandated to either move up to JDeveloper 11, or consider switching to eclipse, or even VS2008 and run .NET services from IIS. I have seen work-around solutions using TopLink and Jdev 11. Are there plans to revive this feature in the near future? We're now looking at switching to .NET since we could scrap our OAS instances and use IIS to publish web services. The only reason we were sticking with Oracle was the ease in converting all our existing package to web services with Jdev.
Is anyone else in the same situation. If so, what solutions are you considering?Hi,
there are a lot of option to make plsql web services .
First you can stay with jdev 10.1.3
Use the xmldb servlets
use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
thanks Edwin -
Problem in generate Java from PL SQL package in Jdeveloper
Hi
i have problem in create java class from PL SQL package in JDeveloper.
I use Database navigator of jdeveloper and right click on a package and choose Generate Java then in Jpublisher window choose my view Controller and accept other default values.
I call methods of generated class in the Action of a button in my JSP page, but when I click the button it throw null pointer exception !!! i fund one of generated method return null and it lead to this exception.
protected DefaultContext __tx = null;
public DefaultContext getConnectionContext() throws SQLException {
if (__tx==null){
__tx = (getConnection()==null) ? DefaultContext.getDefaultContext() : new DefaultContext(getConnection());
return __tx;
public Connection getConnection() throws SQLException
if (__onn!=null) return __onn;
else if (__tx!=null) return __tx.getConnection();
else if (__dataSource!=null) __onn= __dataSource.getConnection();
return __onn;
i try to generate class in Model project and create DataControl for that and use method action but noting change and i get null pointer again!!
Jdeveloper Versino = 11.1.1.7.0Let me ask you another question: Why do you generate java from the package at all?
Where do you want to call the package?
Back to your question: you should see code like
public void setDataSourceLocation(String dataSourceLocation) throws SQLException {
javax.sql.DataSource dataSource;
try {
Class cls = Class.forName("javax.naming.InitialContext");
Object ctx = cls.newInstance();
java.lang.reflect.Method meth = cls.getMethod("lookup", new Class[] { String.class });
dataSource = (javax.sql.DataSource) meth.invoke(ctx, new Object[] { "java:comp/env/" + dataSourceLocation });
setDataSource(dataSource);
} catch (Exception e) {
throw new java.sql.SQLException("Error initializing DataSource at " + dataSourceLocation + ": " + e.getMessage());
in the generated code. This code look up a datasource (which you have defined e.g. on the Weblogic Server) by calling the method
setDataSourceLocaltion("jdbc/HRConnDS");
This look up the datasource nad stores it in the class variable.
Timo -
Call a unix script from pl/sql package
Hi,
Using 11.2.0.3 on AIX.
Is it possible to call unix script from pl/sql package?
I am cretaing a file in a directory but would like this to automatically be written to an archive directory as well.
Could either use 2 utl_file.put_lines to 2 separate directories or 1 utl_file and cal script to archive file in another directory.?
Thoughts?
Thanksuser5716448 wrote:
What am I doing wrong?think how file name will look like:
SQL> select 'file_name' || to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
'FILE_NAME'||TO_CHAR(SYSDATE
file_name15/08/2012 11:47:51Will AIX swallow such name? Obviously not. And, unfortunately, UTL_FILE.FCOPY doesn't raise an error in such case. So use someting like:
UTL_FILE.FCOPY ('SOURCE_DIR',v_FILE_NAME,'DEST_DIR',v_file_name||to_char(sysdate,'DD_MM_YYYY_HH24_MI_SS'));SY. -
Rest based webservices from plsql procedures/packages
Guyz.
Please let me know How to create Rest based webservices in jdeveloper tool from plsql procedures/packages.
Im very much in need
Thanks,Hi User ,
Welcome to OTN !!
You can refer to these links and figure out -
http://docs.oracle.com/cd/E16162_01/user.1112/e17455/dev_web_services.htm#CHDJIFAE
http://theblasfrompas.blogspot.com/2011/03/developing-restful-web-services-from.html
Also for calling pl/sql packages from Java , use soemthing like this - http://www.coderanch.com/t/302171/JDBC/databases/execute-PL-SQL-program-Java -
Trouble when creating webservice from PL/SQL via jdeveloper
Hi,I'm new comer of this world,
I've a pl/sql like this:
package MY_WS_API is
type record_set is ref cursor;
PROCEDURE Get_User_Info(p_user_id VARCHAR2,
p_rep_id VARCHAR2,
p_flag out number,
p_msg out varchar2,
p_recordset out record_set);
end MY_WS_API;
when I using jdeveloper trying to publish it as a webservice, in the step 4 of the wizzard poping me choose the program unit to expose, the PROCEDURE Get_User_Info is not available and told me "Ref cursor Type is not supported due to a jdbc limitation and Ref Cursor Types are only supported for use of return type".
THE QUESTION is:
1.the cursor I used is of return type,I'm not very understanding the "why not" message upon.
2.in such case , need I trans the return cursor into Object[] if have to?
3.any other limitation for generating WS from PL/SQL using jdeveloper?
Thanks!I had the same problem and found that JDeveloper uses the thin driver to connect to oracle, this driver doesn't support ref cursors or xmltypes etc. You have to assemble your own web service using the webservicesassembler command line utility (i.e. wsa.jar). This link should provide you with all you need:
http://download-west.oracle.com/docs/cd/B25221_04/web.1013/b14434/wsassemble.htm -
Generating Webservices from PL/SQL Problem
Hello,
when I try to automatically generate a webservice from my pl/sql package, I cannot choose a specific procedure.
The "why not" button tells me, that there is no xml schema mapping or serializer available.
my question:
The pl/sql procedures output parameter are tables, like:
Spec:
TYPE my_type IS TABLE OF t_my_table.id%TYPE
INDEX BY NATURAL;
Body:
procedure .... (
out_param OUT my_type;
Is it generally possible to autogenerate this kind of output parameter as webservice or have I missed something ?
Do I have to use java instead ?
Thank you for your help,
FrankHi,
Within the package dbms_xmlquery there is a procedure called setDateFormat which you can use to set a format mask.
But the format mask must be one recognised by the java.text.SimpleDateFormat class. an example would be.
dbms_xmlquery.setDateFormat(lc_xmlgen_contex, 'dd.MM. yyyy');
Hope this helps -
Passing / parsing XML String IN / OUT from PL / SQL package
Hello, People !
I am wondering where can I find exact info (with code sample) about following :
We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
and the return some kind of cursor thru I can loop and insert data into
different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
I looked online many site for related info - can't find what I am looking
for - seems like should be a common question.
Thanx a lot !Hello, People !
I am wondering where can I find exact info (with code sample) about following :
We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
and the return some kind of cursor thru I can loop and insert data into
different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
I looked online many site for related info - can't find what I am looking
for - seems like should be a common question.
Thanx a lot ! -
Calling Webservice from Pl/sql
Hi All,
Can any one give me a detailed example, to call a web service from a pl/sql package. preferably by POSt method.
Thank you!check this out for some ideas: http://www.bloggingaboutoracle.org/archives/calling-web-services-from-plsql
-
BizTalk 2013R2 Developer Edition from Gallery - SQL Expired!!
I an a MSDN ultimate subscription holder and I have created a virtual machines within Azure from the Gallery. I have select the BizTalk 2013R2 Developer Edition from the gallery which has initially been great and save me a lot of time with
the setup. Unfortunately after only a couple of weeks my SQL license has expired.
As I did not select any form of evaluation edition I would not expect software licenses to expire when they are provisioned from the gallery whenever. As I understand it as an MSDN ultimate customer I am covered to license BizTalk Developer Edition
and indeed SQL which come as part of the gallery VM.
I've seen a number of posts online around this with no solution and I was wondering if you have a view on this.
Have I picked up the wrong understanding or is their a defect with the BizTalk 2013R2 Developer edition gallery image. A colleague recently reported the same thing happened with BizTalk 2013R2 standard edition image.
Any help and advice would be appreciate as I am stuck if SQL has expired. I don't see the point in provisioning a new gallery image if the same problem will happen.
It is very convenient provisioning from the gallery but if the licenses expire then they become less useful and very annoying. I could understand if I provisioned an evaluation copy but this was not the case here.
Cheers
StephenI have had no timely response from Microsoft on this yet, despite trying my best to seek assistance from them to help fix their defect.
Anyway I did a fresh search online and came accross this which has worked for me
https://www.phidiax.com/blog/post/Azure-Gallery-Image-for-BizTalk-Server-SQL-Server-evaluation-period-has-expired
If you have access to a valid copy of SQL Server 2014 Developer Edition then you can perform an Edition Upgrade and go from SQL 2014 Enterprise Evaluation Edition to SQL 2014 Developer Edition. Once I did this and restarted SQL Services I was
back up and running.
I suspect Microsoft will need to do this with the base gallery image and then re-load it whenever they can be bothered getting around to it OR whenever a customer with an Azure technical support contract raises it! No pay, no technical support outside
this forum.
I have not tried again to fire up a new 2013R2 Developer Edition image from the gallery to see if this is fixed yet.
Hopefully this helps anyone in the same boat as me. If you do not have access to SQL Server 2014 Developer Edition (via say msdn subscription) to perform this upgrade then I'm afraid you will still have difficulty resolving this. -
Issue generating java from pl/sql package
Hi,
In JDeveloper (11.1.1.6) I am having an issue generating java from a pl/sql package. When I am in the database navigator I right click on the package and select "generate java". This produces some java files, some sqlj files and a <package_name>.javatmp file. When a collegue does the same all files are generated with a .java extension. Can anyone tell me what I can do to generate all java files?
Thanks,
GraemeIt turns out that I was running against a 64-bit JDK. (1.6.0_41.)
When I changed this to run against a 32 bit JDK (also 1.6.0_41) my problem went away.
It might be worth noting that my machine is 64 bit. -
Calling a webservice from Pl/SQL
Hi,
I have created a function to call a webservice but I am getting the following error
ORA-20000: soap:Client - System.Web.Services.Protocols.SoapException: Server
did not recognize the value of HTTP Header SOAPAction: ConversionRate.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at
System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage
message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
ORA-06512: at "APPS.SOAP_API", line 54
ORA-06512: at "APPS.SOAP_API", line 81
ORA-06512: at "APPS.PKG_MY_WEBSERVICE", line 12
The Packages code are as follow:
CREATE OR REPLACE PACKAGE soap_api AS
TYPE t_request IS RECORD (
method VARCHAR2(256),
namespace VARCHAR2(256),
body VARCHAR2(32767),
envelope_tag VARCHAR2(30)
TYPE t_response IS RECORD
doc XMLTYPE,
envelope_tag VARCHAR2(30)
FUNCTION new_request(p_method IN VARCHAR2,
p_namespace IN VARCHAR2,
p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
RETURN t_request;
PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
p_name IN VARCHAR2,
p_type IN VARCHAR2,
p_value IN VARCHAR2);
FUNCTION invoke(p_request IN OUT NOCOPY t_request,
p_url IN VARCHAR2,
p_action IN VARCHAR2)
RETURN t_response;
FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
p_name IN VARCHAR2,
p_namespace IN VARCHAR2)
RETURN VARCHAR2;
END soap_api;
CREATE OR REPLACE PACKAGE BODY soap_api AS
FUNCTION new_request(p_method IN VARCHAR2,
p_namespace IN VARCHAR2,
p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
RETURN t_request AS
l_request t_request;
BEGIN
l_request.method := p_method;
l_request.namespace := p_namespace;
l_request.envelope_tag := p_envelope_tag;
RETURN l_request;
END;
PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
p_name IN VARCHAR2,
p_type IN VARCHAR2,
p_value IN VARCHAR2) AS
BEGIN
p_request.body := p_request.body||'<'||p_name||' xsi:type="'||p_type||'">'||p_value||'</'||p_name||'>';
END;
PROCEDURE generate_envelope(p_request IN OUT NOCOPY t_request,
p_env IN OUT NOCOPY VARCHAR2) AS
BEGIN
p_env := '<'||p_request.envelope_tag||':Envelope xmlns:'||p_request.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/" ' ||
'xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">' ||
'<'||p_request.envelope_tag||':Body>' ||
'<'||p_request.method||' '||p_request.namespace||' '||p_request.envelope_tag||':encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' ||
p_request.body ||
'</'||p_request.method||'>' ||
'</'||p_request.envelope_tag||':Body>' ||
'</'||p_request.envelope_tag||':Envelope>';
END;
PROCEDURE show_envelope(p_env IN VARCHAR2) AS
i PLS_INTEGER;
l_len PLS_INTEGER;
BEGIN
i := 1; l_len := LENGTH(p_env);
WHILE (i <= l_len) LOOP
DBMS_OUTPUT.put_line(SUBSTR(p_env, i, 60));
i := i + 60;
END LOOP;
END;
PROCEDURE check_fault(p_response IN OUT NOCOPY t_response) AS
l_fault_node XMLTYPE;
l_fault_code VARCHAR2(256);
l_fault_string VARCHAR2(32767);
BEGIN
l_fault_node := p_response.doc.extract('/'||p_response.envelope_tag||':Fault',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/');
IF (l_fault_node IS NOT NULL) THEN
l_fault_code := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultcode/child::text()',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
l_fault_string := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultstring/child::text()',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
RAISE_APPLICATION_ERROR(-20000, l_fault_code || ' - ' || l_fault_string);
END IF;
END;
FUNCTION invoke(p_request IN OUT NOCOPY t_request,
p_url IN VARCHAR2,
p_action IN VARCHAR2)
RETURN t_response AS
l_envelope VARCHAR2(32767);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response t_response;
BEGIN
generate_envelope(p_request, l_envelope);
show_envelope(l_envelope);
l_http_request := UTL_HTTP.begin_request(p_url, 'POST','HTTP/1.1');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_envelope));
UTL_HTTP.set_header(l_http_request, 'SOAPAction', p_action);
UTL_HTTP.write_text(l_http_request, l_envelope);
l_http_response := UTL_HTTP.get_response(l_http_request);
UTL_HTTP.read_text(l_http_response, l_envelope);
UTL_HTTP.end_response(l_http_response);
l_response.doc := XMLTYPE.createxml(l_envelope);
l_response.envelope_tag := p_request.envelope_tag;
l_response.doc := l_response.doc.extract('/'||l_response.envelope_tag||':Envelope/'||l_response.envelope_tag||':Body/child::node()',
'xmlns:'||l_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/"');
-- show_envelope(l_response.doc.getstringval());
check_fault(l_response);
RETURN l_response;
END;
FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
p_name IN VARCHAR2,
p_namespace IN VARCHAR2)
RETURN VARCHAR2 AS
BEGIN
RETURN p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getstringval();
END;
END soap_api;
SHOW ERRORS
CREATE OR REPLACE PACKAGE pkg_my_webservice IS
FUNCTION call_myfunction(vp_parameter1 VARCHAR2,vp_parameter2 VARCHAR2) RETURN VARCHAR2;
END pkg_my_webservice;
CREATE OR REPLACE PACKAGE BODY pkg_my_webservice IS
vg_funciton_fnc VARCHAR2(256):='ConversionRate';
vg_ws_address VARCHAR2(255):='http://www.webservicex.net/CurrencyConvertor.asmx';
FUNCTION call_myfunction(vp_parameter1 VARCHAR2,vp_parameter2 VARCHAR2)
RETURN VARCHAR2 AS
ol_req soap_api.t_request;
ol_resp soap_api.t_response;
BEGIN
ol_req:=soap_api.new_request(vg_funciton_fnc,'xmlns="'||vg_ws_address||'"');
soap_api.add_parameter(ol_req,'string1','partns:string',vp_parameter1);
soap_api.add_parameter(ol_req,'string2','partns:string',vp_parameter1);
ol_resp:=soap_api.invoke(ol_req,vg_ws_address,vg_funciton_fnc);
RETURN soap_api.get_return_value(ol_resp,'result','xmlns:m="'||vg_ws_address||'"');
END call_myfunction;
END pkg_my_webservice;
-----------------------------------------------------------------------------------------------------------------------------------Hi,
The soap_api package internally uses the utl_http api. I used the utl_http package directly and it works for me. Below is the code for the call, you will have to substitute the variables to suit your setup..
Hope this Helps
Thanks
CREATE OR REPLACE FUNCTION get_webservice_dets(p_emp_number IN VARCHAR2
,p_eff_date IN DATE)
RETURN VARCHAR2
IS
lc_proc VARCHAR2(50) := 'get_webservice_dets';
ln_error_stg NUMBER := 0;
lc_eff_date VARCHAR2(50) := NULL;
soap_request VARCHAR2(32767);
soap_respond VARCHAR2(32767);
-- HTTP variables
req utl_http.req;
resp utl_http.resp;
-- Store the Webservice URL in a Profile Option and change for each environment
lc_wsdl_url VARCHAR2(32767) := FND_PROFILE.VALUE('XXERP_WEBSRVC_URL');
-- return Values
lc_retval VARCHAR2(32767);
lc_response VARCHAR2(32767);
lc_xml_ext_str VARCHAR2(100) := '/env:Envelope/env:Body/OutputParameters/';
lc_xml_ext_unit VARCHAR2(50) := '/text()';
lc_xmlns_ns1_url VARCHAR2(240) := 'xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/APPS/XXERP_SOA_HCM_PKG/GET_SUPERVISOR_NO/"';
lc_xmlns_env_url VARCHAR2(240) := 'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"';
lc_xmlns_xsi_url VARCHAR2(240) := 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
lc_xmlns_url VARCHAR2(240) := 'xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/APPS/XXERP_SOA_HCM_PKG/GET_SUPERVISOR_NO/"';
lc_xml_namespace VARCHAR2(5000) := lc_xmlns_env_url||' '||lc_xmlns_xsi_url||' '||lc_xmlns_url;
lc_xmlns_soap_url VARCHAR2(240) := 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"';
lx_Response XMLTYPE;
BEGIN
ln_error_stg := 10;
IF NVL(lc_wsdl_url,'X') <> 'X' THEN
-- Format the date received as required by the Webservice i.e. - 'YYYY-MM-DDTHH:MI:SS+01:00'
lc_eff_date := REPLACE(TRIM(TO_CHAR(TRUNC(p_eff_date),'YYYY-MM-DD HH:MI:SS')),' ','T')||'+01:00';
-- Form a SOAP Envelope - Exact envelope can be obtained by invoking the above EndPoint URL in a browser session with required
-- parameters and then clicking on the XML Source
soap_request:= '<soap:Envelope '||lc_xmlns_soap_url||'>
<soap:Body '||lc_xmlns_ns1_url||'>
<ns1:InputParameters>
<ns1:P_EMPLOYEE_NUMBER>'||p_emp_number||'</ns1:P_EMPLOYEE_NUMBER>
<ns1:P_DATE>'||lc_eff_date||'</ns1:P_DATE>
</ns1:InputParameters>
</soap:Body>
</soap:Envelope>';
-- Initiate the HTTP request, don't forget to pass in the POST and HTTP/1.1
req := UTL_HTTP.BEGIN_REQUEST(lc_wsdl_url, 'POST','HTTP/1.1');
ln_error_stg := 20;
-- Set the HTTP Request Headers
UTL_HTTP.SET_HEADER(req, 'Content-Type', 'text/xml'); -- since we are dealing with plain text in XML documents
ln_error_stg := 40;
UTL_HTTP.SET_HEADER(req, 'Content-Length', LENGTH(soap_request));
ln_error_stg := 50;
-- Set the SOAP Action to the Operation Name
-- The function Name <getSupervisorID> should match the Webservice Operation Name in SOA
UTL_HTTP.SET_HEADER(req, 'SOAPAction','getSupervisorID'); -- required to specify this is a SOAP communication
ln_error_stg := 60;
-- Append the SOAP Envelope to the HTTP request Header
UTL_HTTP.WRITE_TEXT(req, soap_request);
ln_error_stg := 70;
-- Fetch the HTTP response from the Webservice - This will contain the SOAP Envelope response
-- that needs to be processed downstream
resp := UTL_HTTP.GET_RESPONSE(req);
ln_error_stg := 80;
-- Extract the HTTP response and store in a String Variable
-- READ_TEXT is a specific method exposed to read the SOAP envelope returned from Webservice
-- READ_LINE will read the entire HTML response back from the Server..
UTL_HTTP.READ_TEXT(resp, lc_retval);
ln_error_stg := 90;
-- Create an XML Document from the String returned by the HTTP response..
lx_Response := SYS.XMLTYPE.CREATEXML(lc_retval);
ln_error_stg := 110;
-- If the response is not null then extract the string value of the required output parameter
-- the env: tag needs to be qualified with a corresponding namespace.
IF lx_Response IS NOT NULL THEN
lc_response := lx_Response.extract(lc_xml_ext_str||'PERSON_ID'||lc_xml_ext_unit,lc_xml_namespace).getstringval();
ELSE
DBMS_OUTPUT.PUT_LINE('XMLTYPE Doc returns NULL !!');
lc_response := NULL;
END IF;
ln_error_stg := 120;
-- End the response, otherwise you get
-- UTL_HTTP.TOO_MANY_REQUESTS exception after 5 tries
UTL_HTTP.END_RESPONSE(resp);
ELSE
DBMS_OUTPUT.PUT_LINE('Web Service URL not populated, please provide a value for the Profile Option XXERP: Web Service URL');
lc_response := NULL;
END IF;
RETURN lc_response;
EXCEPTION
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
UTL_HTTP.END_RESPONSE(resp);
RETURN NULL;
WHEN UTL_HTTP.END_OF_BODY THEN
UTL_HTTP.END_RESPONSE(resp);
RETURN NULL;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR @'||ln_error_stg||': '||SQLERRM);
UTL_HTTP.END_RESPONSE(resp);
RETURN NULL;
END get_webservice_dets;
Maybe you are looking for
-
Dear, I have Oracle 11g and APEX in Win XP machine. EM also configured. To get PDF printing in APEX, I should install Apache FOP. As per the document for PDF printing configuration, I am not getting the EM console for OC4J. (for reports and forms, OC
-
Custom button skin with scaleGrid 9 slice image does not appear in Design Mode
So in a custom button skin I have a nine sliced image, and then throw that onto an MXML page. In design view, I cannot get the component to show the image that I've thrown on it. Unless I do a hack on the MXML page by adding the image in it's scaleGr
-
Account generation workflow custom process not visible in lov
Hi guru, i have created a sample process in "Project Supplier Invoice Account Generation". but when i upload the work flow in data base by the concurrent program . i dont find the sample process in " account generation window" in GL. Please help guru
-
PS3 and XBOX360 help please!!!
OK...I recently decided to divorce myself from Windoze and bought an IMac...love it!!! Everything just worked BUT I then got the new Airport Extreme Basestation...it looked cool and was supposed to be faster. I now cannot get my XBOX 360 and PS3 to w
-
Hitting "save" is closing my documents & driving me nuts
Recently, anytime I hit "save", the document automatically closes. This happens using various programs (FTP software, Photoshop, Text-wrangler, Text-edit etc). Its driving me nuts. How can I stop this? Im using a macbook pro running 10.6.8 Ive had th