This discussion is archived
5 Replies Latest reply: Nov 26, 2012 10:20 PM by Sachinmrt RSS

Web Service used in Form Builder

Sachinmrt Explorer
Currently Being Moderated
Hello Everyone,

I use the given below web service :-

http://122.160.71.237:4300/GIRWebServices/GIRWebServices/CommonService.asmx?wsdl

and create a jar file from jdeveloper. My Stub code is :-

package mypackage1;
import oracle.soap.transport.http.OracleSOAPHTTPConnection;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.w3c.dom.Element;
import java.util.Vector;
import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
import java.net.URL;
import org.apache.soap.Envelope;
import org.apache.soap.Body;
import org.apache.soap.messaging.Message;
import java.util.Properties;
/**
* Generated by the Oracle JDeveloper 10g Web Services Stub/Skeleton Generator.
* Date Created: Fri Nov 16 17:00:43 GMT+05:30 2012
* WSDL URL: http://122.160.71.237:4300/GIRWebServices/GIRWebServices/CommonService.asmx?wsdl
*/

public class CommonServiceStub extends WrappedDocLiteralStub
{
public CommonServiceStub()
{
m_httpConnection = new OracleSOAPHTTPConnection();
Properties props = new Properties();
props.put(OracleSOAPHTTPConnection.AUTH_TYPE, "basic");
props.put(OracleSOAPHTTPConnection.USERNAME, "your_username");
props.put(OracleSOAPHTTPConnection.PASSWORD, "your_password");
props.put(OracleSOAPHTTPConnection.REALM, "ARealm");
m_httpConnection.setProperties(props);
}

public static void main(String[] args)
{
try
{
CommonServiceStub stub = new CommonServiceStub();
// Add your own code here.

}
catch(Exception ex)
{
ex.printStackTrace();
}

}

private String _endpoint = "http://122.160.71.237:4300/GIRWebServices/GIRWebServices/CommonService.asmx";

public String getEndpoint()
{
return _endpoint;
}

public void setEndpoint(String endpoint)
{
_endpoint = endpoint;
}

private OracleSOAPHTTPConnection m_httpConnection = null;
private SOAPMappingRegistry m_smr = null;

public String GetGirdata(String Model_No, String Issue_Branch, String Part_Minor_Code, String Make_Company) throws Exception
{
URL endpointURL = new URL(_endpoint);

Envelope requestEnv = new Envelope();
Body requestBody = new Body();
Vector requestBodyEntries = new Vector();

String wrappingName = "GetGirdata";
String targetNamespace = "http://tempuri.org/";
Vector requestData = new Vector();
requestData.add(new Object[] {"Model_No", Model_No});
requestData.add(new Object[] {"Issue_Branch", Issue_Branch});
requestData.add(new Object[] {"Part_Minor_Code", Part_Minor_Code});
requestData.add(new Object[] {"Make_Company", Make_Company});

requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
requestBody.setBodyEntries(requestBodyEntries);
requestEnv.setBody(requestBody);

Message msg = new Message();
msg.setSOAPTransport(m_httpConnection);
msg.send(endpointURL, "http://tempuri.org/GetGirdata", requestEnv);

Envelope responseEnv = msg.receiveEnvelope();
Body responseBody = responseEnv.getBody();
Vector responseData = responseBody.getBodyEntries();

return (String)fromElement((Element)responseData.elementAt(0), java.lang.String.class);
}
}


When I run this code in JDeveloper than this message come:-

Process exited with exit code 128.


I don't now why this message come. Actually i am new in form builder and jdeveloper.
After that i create the jar file and use in form builder by Import Java Classes.
Programme unit created, and code is :-

PACKAGE BODY CommonServiceStub IS

--
-- DO NOT EDIT THIS FILE - it is machine generated!
--

args JNI.ARGLIST;

-- Constructor for signature ()V
FUNCTION new RETURN ORA_JAVA.JOBJECT IS
BEGIN
args := NULL;
RETURN (JNI.NEW_OBJECT('mypackage1/CommonServiceStub', '()V', args));
END;

-- Method: main ([Ljava/lang/String;)V
PROCEDURE main(
a0 ORA_JAVA.JARRAY) IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
JNI.CALL_VOID_METHOD(TRUE, NULL, 'mypackage1/CommonServiceStub', 'main', '([Ljava/lang/String;)V', args);
  END;

  -- Method: getEndpoint ()Ljava/lang/String;
  FUNCTION getEndpoint(
    obj   ORA_JAVA.JOBJECT) RETURN VARCHAR2 IS
  BEGIN
    args := NULL;
    RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'mypackage1/CommonServiceStub', 'getEndpoint', '()Ljava/lang/String;', args);
  END;

  -- Method: setEndpoint (Ljava/lang/String;)V
  PROCEDURE setEndpoint(
    obj   ORA_JAVA.JOBJECT,
    a0    VARCHAR2) IS
  BEGIN
    args := JNI.CREATE_ARG_LIST(1);
    JNI.ADD_STRING_ARG(args, a0);
    JNI.CALL_VOID_METHOD(FALSE, obj, 'mypackage1/CommonServiceStub', 'setEndpoint', '(Ljava/lang/String;)V', args);
  END;

  -- Method: GetGirdata (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
  FUNCTION GetGirdata(
    obj   ORA_JAVA.JOBJECT,
    a0    VARCHAR2,
    a1    VARCHAR2,
    a2    VARCHAR2,
    a3    VARCHAR2) RETURN VARCHAR2 IS
  BEGIN
    args := JNI.CREATE_ARG_LIST(4);
    JNI.ADD_STRING_ARG(args, a0);
    JNI.ADD_STRING_ARG(args, a1);
    JNI.ADD_STRING_ARG(args, a2);
    JNI.ADD_STRING_ARG(args, a3);
    RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'mypackage1/CommonServiceStub', 'GetGirdata', '(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;', args);
  END;


BEGIN
  NULL;
END;



and call this webservice on button click. Button code is -


DECLARE
jo ora_java.jobject;
rv varchar2(1500);
ex ora_java.jobject;
BEGIN
jo := CommonServiceStub.new;

rv:=CommonServiceStub.GetGirdata(jo ,'UNARMMED','RTSTO01','00251','OFC192F');

EXCEPTION
WHEN ORA_JAVA.JAVA_ERROR then
  message (' Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR );
  message('');
WHEN ORA_JAVA.EXCEPTION_THROWN then
  ex := ORA_JAVA.LAST_EXCEPTION;
  message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
  message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
END;



Form Builder show the error on  this code line

message(' Unable to call out to Java ' ||Exception_.toString (ex ) );


Error Message is

Exception_.toString (ex ) Must be declared.

So now two problem.

1- Process exited with exit code 128. Is it error code?? If it is not error then ok. Otherwise please help me what should i do??

2- Exception_.toString (ex ) Must be declared.
Form builder why show this error.

Dear All Senior I am new So please help me and guide me as beginner. and sorry for my english.

I use this link for create the Jar file in jdeveloper-

http://www.oracle.com/technetwork/developer-tools/forms/ws-10-1-3-from-forms-098038.html

My System Confiquration is :-

My Form Builder is :- Forms [32 Bit] Version 10.1.2.0.2 (Production)
OS is :- Windows Server 2003 R2

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points