Overloading hassle with no args, different return types

We're trying to create a document object that can be parsed from XML with xerces and then used as the model for a jtree and a styled-text editor. That means we want to:
1. subclass stuff from org.w3c.dom
2. implement interfaces from javax.swing.tree
3. implement interfaces from javax.swing.text
We figured that since they all represent similar tree structures, this would be a nice and clever thing to do.
Hit a snag this morning:
* org.w3c.dom.Node.getAttributes() returns NamedNodeMap
* javax.swing.text.Element.getAttributes() returns AttributeSet
So, our class gets a compile error on the conflicting return types for what it thinks is the same method.
Any suggestions for what to do? Abandoning xerces isn't an option, and rewriting styled text ourselves isn't practial either.
--Chris (invalidname)

This is the problem with multiple inheritance. In C++, the problem is more pronounced because you can inherit two implmentations of the same method.
In Java, whenever you inherit two methods with the same signature, even if the return types are the same, you have a similar problem. These two methods will likely have two different contracts, and you cannot fulfuill both contracts with one method.
Example:
interface Graphical { /** Draw object on screen */ void draw() { } }
interface CardDeck { /** Draw a card */ void draw() { } }
class CardGame implements Graphical, CardDeck { /** ??? */ void draw() { } }It is unfortunate that you're inheriting two different getAttributes() methods. You'll have to use composition and delegation instead of inheritance to get around the problem.

Similar Messages

  • Two methods with same name but different return type?

    Can I have two methods with same name but different return type in Java? I used to do this in C++ (method overloading or function overloading)
    Here is my code:
    import java.io.*;
    public class Test{
    public static void main(String ar[]){
    try{          
    //I give an invalid file name to throw IO error.
    File file = new File("c:/invalid file name becasue of spaces");
    FileWriter writer = new FileWriter(file ,true);
    writer.write("Test");
    writer.close();     
    } catch (IOException IOe){
         System.out.println("Failure");
    //call first method - displays stack trace on screen
         showerr(NPe);
    //call second method - returns stack trace as string
            String msg = showerr(NPe);
            System.out.println(msg);
    } // end of main
    public static void showerr(Exception e){
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
         try{
         pw.close();
         sw.close();
         catch (IOException IOe){
         IOe.printStackTrace();     
         String stackTrace = sw.toString();
         System.out.println("Null Ptr\n" +  stackTrace );
    }//end of first showerr
    public static String showerr(Exception e){
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
         try{
         pw.close();
         sw.close();
         catch (IOException IOe){
         IOe.printStackTrace();     
         return sw.toString();
    }//end of second showerr
    } // end of class
    [\code]

    Overloading is when you have multiple methods that have the same name and the same return type but take different parameters. See example
    public class Overloader {
         public String buildError(Exception e){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( e.getClass().getName() )
                   .append( " : " )
                   .append( e.getMessage() ) ;
              return buffer.toString() ;
         public String buildError(String msg){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( msg ) ;
              return buffer.toString() ;
         public String buildErrors(int errCount){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( "There have been " )
                   .append( errCount )
                   .append( " errors encountered.")  ;
              return buffer.toString() ;
    }Make sense ???
    Regards,

  • Same functions with different return types in C++

    Normally the following two functions would be considered the same:
    int getdata ( char *s, int i )
    long getdata ( char *s, int i )
    Every other compiler we use would resolve both of these to the same function. In fact, it is not valid C++ code otherwise.
    We include some 3rd party source in our build which sometimes messes with our typedefs causing this to happen. We have accounted for all of the function input types but never had a problem with the return types. I just installed Sun ONE Studio 8, Compiler Collection and it is generating two symbols in our libraries every time this occurs.
    Is there a compiler flag I can use to stop it from doing this? I've got over 100 unresolved symbols and I'd rather not go and fix all of them if there is an easier way.

    Normally the following two functions would be
    considered the same:
    int getdata ( char *s, int i )
    long getdata ( char *s, int i )Not at all. Types int and long are different types, even if they are implemented the same way.
    Reference: C++ Standard, section 3.9.1 paragraph 10.
    For example, you can define two functions
    void foo(int);
    void foo(long);
    and they are distinct functions. The function that gets called depends on function overload resolution at the point of the call.
    Overloaded functions must differ in the number or the type of at least one parameter. They cannot differ only in the return type. A program that declares or defines two functions that differ only in their return types is invalid and has undefined behavior. Reference: C++ Standard section 13.1, paragraph 2.
    The usual way to implement overloaded functions is to encode the scope and the parameter types, and maybe the return type, and attach the encoding to the function name. This technique is known as "name mangling". The compiler generates the same mangled name for the declaration and definition of a given function, and different mangled names for different functions. The linker matches up the mangled names, and can tell you when no definition matches a reference.
    Some compilers choose not to include the return type in the mangled name of a function. In that case, the declaration
    int foo(char*);
    will match the definition
    long foo(char*) { ... }
    But it will also match the definitions
    myClass foo(char*) { ... }
    double foo(char*) { ... }
    You are unlikely to get good results from such a mismatch. For that reason, and because a pointer-to-function must encode the function return type, Sun C++ always encodes the function return type in the mangled name. (That is, we simplify things by not using different encodings for the same function type.)
    If you built your code for a 64-bit platform, it would presumably link using your other compilers, but would fail in mysterious ways at run time. With the Sun compiler, you can't get into that mess.
    To make your program valid, you will have to ensure your function declarations match their definitions.

  • Premature EOF encountered with Document as a return type

    I have created a web service that returns a Document object. I have successfully deployed the web service to my local OC4J standalone (9.0.3), and tested it within JDeveloper with a stub. The same web service is deployed to our test server running 9iAS 9.0.2, with OC4J 9.0.2. When I change my stub to point to the test server, I get the following error rather than the Document returned:
    [SOAPException: faultCode=SOAP-ENV:IOException; msg=Premature EOF encountered; targetException=java.io.EOFException: Premature EOF encountered]
    Thinking this was a OC4J version issue, I installed 9.0.3 standalone on the same machine. I am able to navigate to the web services page for my web service successfully, invoke the web service, and see the correct Document embedded within the SOAP response. I was unable to do this on the 9.0.2 OC4J instance. Unfortunately, I get the same error when running the stub from JDeveloper and pointing to the 9.0.3 web service.
    In an probably unrelated note, I am trying to use the web services portlet, pointing to my stub to call my web service. With this, I get the following error:
    ERROR: Failed to handle HTTP Request
    oracle.xml.parser.v2.XMLDOMException: Object not supported in current implementation.
         at oracle.xml.parser.v2.XMLDocument.importNode(XMLDocument.java:1303)
         at oracle.portal.provider.v2.webservice.RPCWebServiceRenderer.expandResult(Unknown Source)
         at oracle.portal.provider.v2.webservice.RPCWebServiceRenderer.invokeService(Unknown Source)
         at oracle.portal.provider.v2.webservice.WebServiceRenderer.renderBody(Unknown Source)
         at oracle.portal.provider.v2.render.RenderManager.render(Unknown Source)
         at oracle.portal.provider.v2.DefaultPortletInstance.render(Unknown Source)
         at oracle.webdb.provider.v2.adapter.soapV1.ProviderAdapter.showPortlet(Unknown Source)
         at oracle.webdb.provider.v2.adapter.soapV1.ProviderAdapter.handleHttp(Unknown Source)
         at java.lang.reflect.Method.invoke(Native Method)
         at oracle.webdb.provider.v2.adapter.SOAPServlet.doHTTPCall(Unknown Source)
         at oracle.webdb.provider.v2.adapter.SOAPServlet.service(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    Thinking this is an xmlparser version issue, not sure which parser is taking precendence, the OC4J_Portal parser, my application parser, or the ORACLE_HOME parser.
    I have thrashed on these issues for a little while, and hopefully I have missed something obvious here. Anything jump out at anyone?
    Thanks!

    Mike,
    Thanks for the response. The reason I am inclined to use Document as a return type is for reuse. Our system is based on the creation of Document representations of content to be displayed, and we use framework code to transform given an xsl. I am trying to establish a pattern for publishing web services right from our existing processes that return the Document. I did play with Element, but would rather not go that way.
    I think my web service is working fine now, actually. (Why it can't be tested from JDev, I'm not sure. I will try the server side proxy as you suggest). It is returning my xml content within the <return> of the response. The problem is transforming the result with an xsl. I have tried the web services portlet, which won't work for me because of my return type, and I'm now trying the OmniPortlet, which seems to be coming tantalizingly close to working ;). Not sure if you have used the OmniPortlet or not, but running it, I can see the return of the web service with my xml, which looks good, but then I get this error:
    3/12/03 8:55 AM omniPortlet: [id=(null), instance=3915_OMNIPORTLET_49587206] XMLData.next => o
    racle.webdb.reformlet.ReformletException: Error occured while fetching XML data.
    Also, I've had problems getting the OmniPortlet to recognize my xsl filter for the xml being returned.
    Anyone have any success using OmniPortlet consuming a web service that returns xml to be transformed with an xsl filter?
    Thanks,
    Jason

  • Populating ComboBox with CFC web service return type query

    I am just now learning Flex and am attempting my first app (I have been a CFer for years).
    Anyway, I am attempting to build an AIR app in Flex that simply has a login with a form to submit information into a database.
    Things are going ok, except I am stumped at something that I think should be simple...populating a combo box. I have a CFC (I am using CFCs as a web service to drive the app) that contains a method that simply returns a query. I want to use the results to populate the combo box display and value. I created the combo box and then dragged the method to the box to have FB create the code. It populates the list but with just [object Object]. This is a piece of cake in CF but I am not stumbling across the correct syntax in Flex. Any pointers would be appreciated.
    Here is my current code.
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           xmlns:users="services.users.*"
                           currentState="login"
                           xmlns:vinlookup="services.vinlookup.*"
                           xmlns:inventory="services.inventory.*"
                           creationComplete="init()">
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                import mx.events.FlexEvent;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.utils.ObjectUtil;
                /*Login Code----------------------------------*/
                private var loginrs:Object;
                //Failed to connect to the wsdl service
                private function GeneralFailed_Handler(e:FaultEvent):void
                    Alert.show(e.fault.faultString, "Error connecting to the service");
                //Login Handler
                protected function submitBtn_clickHandler(event:MouseEvent):void
                    loginUserResult.token = users.loginUser(userName.text, password.text);
                //Result Handler for Account Authentication
                private function loginUserResult_resultHandler(e:ResultEvent):void
                    //check the result
                    //Alert.show(ObjectUtil.toString(e.result),"Login Results")
                    loginrs = new Object();
                    loginrs = e.result;
                    if(loginrs['loggedin'] == 'Y')
                        currentState = 'insertInventory';
                    }else{
                        Alert.show("Try Again Please.");
                /*VIN Lookup Code----------------------------------*/
                private var vinrs:Object;
                //VIN Lookup Handler
                protected function VINSubmitbtn_clickHandler(event:MouseEvent):void
                    getvinInfoResult.token = vinlookup.getvinInfo(vin.text, "BASIC");
                //Result Handler for Account Authentication
                private function vinLookupResult_resultHandler(e:ResultEvent):void
                    //check the result
                    Alert.show(ObjectUtil.toString(e.result),"Lookup Results")
                    vinrs = new Object();
                    vinrs = e.result;
                    if(vinrs == null)
                        Alert.show("The VIN did not decode. Try Again Please.");
                    else
                        bodyStyle.text = vinrs['VARBODYSTYLE'];
                        //Alert.show("Yes!");
                /*Item Type Combo Box Code----------------------------------*/   
                protected function comboBox_creationCompleteHandler(event:FlexEvent):void
                    getItemtypeResult.token = inventory.getItemtype();
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="login"/>
            <s:State name="insertInventory"/>
        </s:states>
        <fx:Declarations>
            <s:CallResponder id="loginUserResult" result="loginUserResult_resultHandler(event)"/>
            <users:Users id="users" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
            <s:CallResponder id="getvinInfoResult" result="vinLookupResult_resultHandler(event)"/>
            <vinlookup:Vinlookup id="vinlookup" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
            <inventory:Inventory id="inventory" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
            <s:CallResponder id="getItemtypeResult"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:Panel width="250" height="150" title="Login" horizontalCenter="0" verticalCenter="0" includeIn="login">
            <mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">
                <mx:FormItem label="User Name">
                    <s:TextInput id="userName"/>
                </mx:FormItem>
                <mx:FormItem label="Password">
                    <s:TextInput id="password" displayAsPassword="true"/>
                </mx:FormItem>
                <mx:FormItem>
                    <s:Button label="Login" id="submitBtn" click="submitBtn_clickHandler(event)"/>
                </mx:FormItem>
            </mx:Form>
        </s:Panel>
        <s:Panel includeIn="insertInventory" width="400" height="400" title="Insert Inventory" horizontalCenter="0" verticalCenter="0">
            <mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">
                <mx:FormItem label="VIN">
                    <s:TextInput id="vin"/>
                </mx:FormItem>
                <mx:FormItem id="vinSubmitbtn">
                    <s:Button label="Decode VIN" id="VINSubmitbtn" click="VINSubmitbtn_clickHandler(event)"/>
                </mx:FormItem>
                <mx:FormItem label="Body Style">
                    <s:TextInput id="bodyStyle"/>
                </mx:FormItem>
                <mx:FormItem label="Item Type">
                    <s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)">
                        <s:AsyncListView list="{getItemtypeResult.lastResult}"/>
                    </s:ComboBox>
                </mx:FormItem>
            </mx:Form>
        </s:Panel>
    </s:WindowedApplication>

    I figured it out with the help of the AS help. I switched to using a DropDownList and the first example in the help.

  • Extend abstract class & implement interface, different return type methods

    abstract class X
    public abstract String method();
    interface Y
    public void method();
    class Z extends X implements Y
      // Compiler error, If I don't implement both methods
      // If I implement only one method, compiler error is thrown for not
      // implementing another method
      // If I implement both the methods,duplicate method error is thrown by 
      //compiler
    The same problem can occur if both methods throw different checked exceptions,or if access modifiers are different..etc
    I'm preparing for SCJP, So just had this weired thought. Please let me know
    if there is a way to solve this.

    Nothing you can do about it except for changing the design.
    Kaj

  • Interfaces having methods of same signature but different return types

    I have two interfaces in two files:
    public interface InterfaceA
    int f();
    public interface InterfaceB
    void f();
    Now I want to write a class that implements these two interfaces. Is it possible? If yes, could you please provide a code example?

    The easiest thing would be to change one of the names! Another approach is to have views of the class implement one or both interfaces.
    Both:
    class C {
        private InterfaceA a = new InterfaceA() {
            public int f() {
                return 0;
        public InterfaceA asA() {
            return a;
        private InterfaceB b = new InterfaceB() {
            public void f() {
        public InterfaceB asB() {
            return b;
    }One:
    class B implements InterfaceB {
        private InterfaceA a = new InterfaceA() {
            public int f() {
                return 0;
        public InterfaceA asA() {
            return a;
        public void f() {
    }

  • Covariant Return Types - J2SE 5.0

    I just read the tech tip regarding the new covariant return types in j2se 5.0
    In the doc, it said that you can now compile two methods with the same signature but with different return types. I was wondering if anyone knew how this would affect what the following expression returns: anObject.getClass().getMethod(aMethodNameString, aClassArray)
    If there are two methods with the same signature except for the return type, how does the above expression know which method to return?

    Never mind, I just found my answer in the javadoc....
    "To find a matching method in a class C: If C declares exactly one public method with the specified name and exactly the same formal parameter types, that is the method reflected. If more than one such method is found in C, and one of these methods has a return type that is more specific than any of the others, that method is reflected; otherwise one of the methods is chosen arbitrarily. "

  • Column Function Return Type Number is forcing to cast to Decimal

    Hi - I am using Oracle 11g Release 11.2.0.2.0 and ODP.NET 4.112.3.0.
    Whenever I am trying to execute a package query with column function and return type is number, it is throwing cast exception whenever I am trying to cast it as GetInt32.
    The workaround we have for now is to get it decimal and cast to Int32, this is going to be painful moving forward because it means that we have to check each of our packages and need to know if each package has column function and do this special casting.
    Is this a known bug?

    Oracle Number is 6.
    Run the below script to your machine and the sample code below so you can see what I am talking about.
    --drop table aninalfarm;
    --drop table birdfarm;
    --drop public synonym animalfarm;
    --drop public synonym birdfarm;
    --drop public synonym birdfarm_Pkg;
    --drop public synonym animalfarm_Pkg;
    create table animalfarm
            (code                                 NUMBER(6),
            description                        varchar2(10));
    create table birdfarm
           (code                               number(6),
           description                         varchar2(10));
    create public synonym  animalfarm for db.animalfarm;
    create public synonym  birdfarm for db.birdfarm;
    grant select, delete, insert, update on  animalfarm to public;
    grant select, delete, insert, update on  birdfarm to public;
    delete from animalfarm;
    delete from birdfarm;
    commit;
    insert into animalfarm (code, description) values(111122, 'Horse');
    insert into animalfarm (code, description) values(111133, 'Chicken');
    insert into animalfarm (code, description) values(111144, 'Cow');
    insert into animalfarm (code, description) values(111155, 'Pig');
    insert into animalfarm (code, description) values(111166, 'Sheep');
    insert into birdfarm (code, description) values(222, 'Pigeon');
    insert into birdfarm (code, description) values(333, 'Sparrow');
    insert into birdfarm (code, description) values(444, 'Chickadee');
    insert into birdfarm (code, description) values(555, 'Blue Jay');
    insert into birdfarm (code, description) values(666, 'Loon');
    commit;
    create or replace package birdfarm_Pkg is
    function get_key_from_desc(bird_name_in in birdfarm.description%type) return number;
    end birdfarm_Pkg;
    create or replace package body birdfarm_Pkg is
    function get_key_from_desc(bird_name_in in birdfarm.description%type) return number is
    RETURN_VALUE birdfarm.code%TYPE;
    BEGIN
           select code into RETURN_VALUE from birdfarm where description = bird_name_in;
           return RETURN_VALUE;
    end get_key_from_desc;
    END birdfarm_Pkg;
    create or replace package animalfarm_Pkg is
    --region Define Record Type for Strong Type REF CURSOR
    TYPE AnimalFarmRecord is
      RECORD(
                      code animalfarm.code%type,
          description animalfarm.description%type,
                      birdfarm_code birdfarm.code%type
    --endregion
    TYPE animalfarmCur is REF CURSOR RETURN AnimalFarmRecord;
    procedure get_code_two_ways(cur_OUT OUT animalfarmCur);
    end animalfarm_Pkg;
    create or replace package body animalfarm_Pkg is
    procedure get_code_two_ways(cur_OUT OUT animalfarmCur) is
    BEGIN
      open cur_OUT for
           select animalfarm.code,
                  animalfarm.description,
                  birdfarm_pkg.get_key_from_desc('Pigeon') birdfarm_code
           from animalfarm
           order by code;
    end get_code_two_ways;
    END animalfarm_Pkg;
    create public synonym birdfarm_Pkg for db.birdfarm_Pkg;
    grant execute on birdfarm_Pkg to public;
    create public synonym animalfarm_Pkg for db.animalfarm_Pkg;
    grant execute on animalfarm_Pkg to public;
    See the sample code below:
                 var conn = new OracleConnection(OraDB);
                conn.Open();
                conn.ClientId = "Sample";
                var command = new OracleCommand
                                      Connection = conn,
                                      CommandText = "DB.animalfarm_Pkg.get_code_two_ways",
                                      CommandType = CommandType.StoredProcedure
                command.Parameters.Add(new OracleParameter
                                       ParameterName = "cur_OUT",
                                       OracleDbType = OracleDbType.RefCursor,
                                       Direction = ParameterDirection.Output
                OracleDataReader dr = command.ExecuteReader(); // C#
                dr.Read();
                var code =dr.GetInt32(dr.GetOrdinal("Code")); //This is ok
                var description = dr.GetString(dr.GetOrdinal("Description"));
                var codeError = dr.GetInt32(dr.GetOrdinal("birdfarm_code"));//Throw invalid cast exception
                                                                            //because it is column function
                conn.Close();
                conn.Dispose();

  • Flex services with multiple return types

    Hello,
    We are creating a webapplication with flex and php.
    Everything is working very good, until we got to the library part of the application.
    Every service so far had only 1 return type (eg: User, Group, ...)
    Now for the library we want to return a ArrayCollection of different types of objects. To be more specific the LibraryService should return a ArrayCollection containing Folder and File objects.
    But how to configure this in Flex (Flash Builder 4 (standard))?
    So far it converts every object to the type Object, i would really like it to be Folder or File
    The only solution we can think of right now is to create a new object Library that will contain 2 ArrayCollections, one of type Folder and one of type File. This could work ofcourse, but I wonder if there is a better solution for this OR that i can configure multiple return types for a service.
    Any ideas/advice is greatly appreciated.

    Normally if you are using Blazeds(Java stuff, i'm sure there should be something similar for php), you can map java objects to that of the AS objects, when you get the data back you are actually seeing the object which is a Folder or a File object rather than just a Object.

  • Stub generated in Jdev9i for webservice with 'Vector' return type

    Hi,
    In the OAF page that I am developing, I am trying to consume a web service generated in SAP PI using Jdeveloper. My Jdeveloper version is 9.0.3.5(I need to use this version since I need to deploy the OAF page in EBS11i). The stub generated based on the WSDL is given below.
    import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    import org.apache.soap.encoding.soapenc.BeanSerializer;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    import org.apache.soap.util.xml.QName;
    import java.util.Vector;
    import org.w3c.dom.Element;
    import java.net.URL;
    import org.apache.soap.Body;
    import org.apache.soap.Envelope;
    import org.apache.soap.messaging.Message;
    * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
    * Date Created: Tue Jan 25 16:12:55 IST 2011
    * WSDL URL: file:/C://Working/XXXXXXX/RegConsComplaint_OB.wsdl
    public class RegConsComplaint_OBServiceStub
      public RegConsComplaint_OBServiceStub()
        m_httpConnection = new OracleSOAPHTTPConnection();
      public static void main(String[] args)
        try
          RegConsComplaint_OBServiceStub stub = new RegConsComplaint_OBServiceStub();
          // Add your own code here.
        catch(Exception ex)
          ex.printStackTrace();
      public String endpoint = "http://XXXXXX:8000/sap/xi/...../RegConsComplaint_OB";
      private OracleSOAPHTTPConnection m_httpConnection = null;
      private SOAPMappingRegistry m_smr = null;
      public Vector RegConsComplaint_OB(Element requestElem) throws Exception
        URL endpointURL = new URL(endpoint);
        Envelope requestEnv = new Envelope();
        Body requestBody = new Body();
        Vector requestBodyEntries = new Vector();
        requestBodyEntries.addElement(requestElem);
        requestBody.setBodyEntries(requestBodyEntries);
        requestEnv.setBody(requestBody);
        Message msg = new Message();
        msg.setSOAPTransport(m_httpConnection);
        msg.send(endpointURL, "http://sap.com/xi/WebService/soap1.1", requestEnv);
        Envelope responseEnv = msg.receiveEnvelope();
        Body responseBody = responseEnv.getBody();
        return responseBody.getBodyEntries();
    }I am wondering whether I will be able to use this stub generated by Jdeveloper since the input type is 'Element' and return type is 'Vector'; while in the Jdeveloper documentation the supported "primitive XML Schema types and arrays of primitive XML Schema types as parameters and return values for web services" do not include either of the two.
    Regards,
    Sujoy

    Hi Sujoy
    I have been having big problems consuming microsoft sharepoint webservices using jDeveloper 9i.
    Problems with jdk version compatability with jDev and NTLM authentication (Sharepoint).
    so switching to db connection using utl_http.
    Can you pls send me the code set for reference at [email protected]
    thanks.
    Regards
    Sachin

  • Native method with String return type

    Hi
    i am implementing a Native method with String Return type.
    i am able call the respective C++ method and my C++ method is printing the String (jstring in c++ code ) correctly
    i but i am getting nullpointerexcepti while loading the string in to my Java String .
    i am sure my java code calling the C++ code beacause my C++ code is printing the value and one more wonder is after the NPE my c++ code able to print the value
    the code follows
    HelloWorld.java
    public class HelloWorld {
         private native String print();
         static {
             System.loadLibrary("HelloWorld");
         public static void main(String[] args) throws InterruptedException,NullPointerException{
              HelloWorld hW= new HelloWorld();
              for(int i=0;;i++){
                   String str= new HelloWorld().print();
                   System.out.println(str);
                   Thread.sleep(10000);
    }and HelloWorld.cpp
    // HelloWorld.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    #include "jni.h"
    #include <stdio.h>
    #include "HelloWorld.h"
    #include <windows.h>
    #include "tchar.h"
    #include "string.h"
    #ifdef _MANAGED
    #pragma managed(push, off)
    #endif
    CHAR cpuusage(void);
    typedef BOOL ( __stdcall * pfnGetSystemTimes)( LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
    static pfnGetSystemTimes s_pfnGetSystemTimes = NULL;
    static HMODULE s_hKernel = NULL;
    void GetSystemTimesAddress()
         if( s_hKernel == NULL )
              s_hKernel = LoadLibrary(_T("Kernel32.dll"));
              if( s_hKernel != NULL )
                   s_pfnGetSystemTimes = (pfnGetSystemTimes)GetProcAddress( s_hKernel, "GetSystemTimes" );
                   if( s_pfnGetSystemTimes == NULL )
                        FreeLibrary( s_hKernel ); s_hKernel = NULL;
    // cpuusage(void)
    // ==============
    // Return a CHAR value in the range 0 - 100 representing actual CPU usage in percent.
    CHAR cpuusage()
         FILETIME               ft_sys_idle;
         FILETIME               ft_sys_kernel;
         FILETIME               ft_sys_user;
         ULARGE_INTEGER         ul_sys_idle;
         ULARGE_INTEGER         ul_sys_kernel;
         ULARGE_INTEGER         ul_sys_user;
         static ULARGE_INTEGER      ul_sys_idle_old;
         static ULARGE_INTEGER  ul_sys_kernel_old;
         static ULARGE_INTEGER  ul_sys_user_old;
         CHAR  usage = 0;
         // we cannot directly use GetSystemTimes on C language
         /* add this line :: pfnGetSystemTimes */
         s_pfnGetSystemTimes(&ft_sys_idle,    /* System idle time */
              &ft_sys_kernel,  /* system kernel time */
              &ft_sys_user);   /* System user time */
         CopyMemory(&ul_sys_idle  , &ft_sys_idle  , sizeof(FILETIME)); // Could been optimized away...
         CopyMemory(&ul_sys_kernel, &ft_sys_kernel, sizeof(FILETIME)); // Could been optimized away...
         CopyMemory(&ul_sys_user  , &ft_sys_user  , sizeof(FILETIME)); // Could been optimized away...
         usage  =
              (ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
              (ul_sys_user.QuadPart   - ul_sys_user_old.QuadPart)
              (ul_sys_idle.QuadPart-ul_sys_idle_old.QuadPart)
              (100)
              (ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
              (ul_sys_user.QuadPart   - ul_sys_user_old.QuadPart)
         ul_sys_idle_old.QuadPart   = ul_sys_idle.QuadPart;
         ul_sys_user_old.QuadPart   = ul_sys_user.QuadPart;
         ul_sys_kernel_old.QuadPart = ul_sys_kernel.QuadPart;
         return usage;
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
        return TRUE;
    #ifdef _MANAGED
    #pragma managed(pop)
    #endif
    JNIEXPORT jstring JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         jstring s=(jstring)cpuusage();
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }actually in the above code below part does that all, in the below code the printf statement printing correctly
    JNIEXPORT jstring JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         jstring s=(jstring)cpuusage();
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }and the NPE i get is
    Exception in thread "main" java.lang.NullPointerException
         at HelloWorld.print(Native Method)
         at HelloWorld.main(HelloWorld.java:10)
    CPU Usage from C++:   6%any solution?
    Thanks
    R
    Edited by: LoveOpensource on Apr 28, 2008 12:38 AM

    See the function you wrote:
    JNIEXPORT jstring JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         _jstring s=(jstring)cpuusage();_
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }Here you try to cast from char to jstring, this is your problem, jstring Object should be created:
    char str[20];
    sprintf(str, "%3d", (int)cpuusage());
    printf("CPU Usage from C++: %s%%\r",str);
    jstring s=env->NewStringUTF(str);
    return s;

  • Posting of cross company transaction with different doc types

    Hi,
    The scenario is:-
    We have two companies X and Y.
    X makes a payment to Y with the following FI entries:-
    Company Code X
    Dr Vendor Y
    Cr Bank HDFC
    Company Code Y
    Dr Bank ICICI
    Cr Customer X
    Now this needs to be a cross company transaction where the doc type for CC X should be vendor Payment 'KZ' while the doc type for CC Y should be a customer reciept with doc type 'DZ'.
    Although I am able to map the accounts in cross company code config I am not able to split the transaction of different company codes with different document types.
    Is there any way we can do this in standard SAP?
    Thanks in advance,
    Nitish

    Hi
    As per your issue ...There are no possibilities to post   in sap with different document types.
    If you want you can post cross company code transactions with one document types
    Regards
    vamsi

  • Same Input name with different data type cause the reflection exception

    I have a proxy contains couple RFCs. Two RFCs contain an argument named IN_COMPANY_CODE with data type of ZTRE_FX_BUKRSTable. Another RFC contains the same argument name of IN_COMPANY_CODE but hold different data type (String). All RFCs are in the same proxy. Complie and build the application with no issue.
    But when I ran the RFC, it generates the reflection exception below:
    Method SAPProxy1.Z_F_Tre_R_Pre_Trade_Fx can not be reflected. --> There was an error reflecting 'In_Company_Code'. > The XML element named 'IN_5fCOMPANY_--5fCODE' from namespace '' references distinct types System.String and MSTRFOREX.ZTRE_FX_BUKRSTable. Use XML attributes to specify another XML name or namespace for the element or types.
    I realize the conflict introduced by the same name with difference data type. But I would like to know if this is fixable as a bug or if there is any best practice and/or some manual intervention to make it work.

    Please install fix from OSS note 506603. After this, right-click .sapwsdl file and select "Run custom tool".

  • Vendor Payment with different document types

    Dear Sapguru,
    We have a scenario where a particular vendor payable is in two different document types for example, RE and KZ.
    When we execute TC F110, the payment proposal is grouping the payments by document type. I.e. it grouped all the documents under type RE and grouped all the documents under type KZ and created two line items in the payment proposal.
    Actually, we want to have a single group consisting of all the document types payable to the vendor.
    We have checked different SAP notes and also verified out system settings, but the problem still remains.
    Can somebody let us know how to group all the open items in a single line item in F110 irrespective of document types.
    Thanks in Advance.
    Regards.,
    Rama

    Dear Naravi,
    the main factor which affects the grouping of items is the Structure ZHLG1:
    ZBUKR
    ABSBU
    LIFNR
    KUNNR
    EMPFG
    WAERS
    ZLSCH
    HBKID
    HKTID
    BVTYP
    SRTGB
    SRTBP
    XINVE
    PAYGR
    UZAWE
    DTWS1
    DTWS2
    DTWS3
    DTWS4
    KIDNO
    All these fields have to coincide, to have a single payment.
    Please check why two documents with different document type are paid into two different payments.
    Read the SAP notes 109233 and 164835 and 305414 as well.
    I hope this helps.
    Mauri

Maybe you are looking for

  • Logical port problem

    Hi All I create logical port in LPCONFIG for a WS and i put the proxy class and logcal port (just variable like abc ) i choose defult port and in runtime i choose webservice and in in call parameters in URL i put the WSDl of the WS i create via se37

  • Adding Drop Down List values from table fields

    Hi all, Recently we have switched from Microsoft's Infopath to Adobe's LiveCycle Designer.  In InfoPath i was able to allow a user to enter data in a table and then use that data as values for a drop downlist, which could in turn be used in another t

  • An annoying Ds.Store file on Desktop keeps coming back.

    Hi, do not know why i have a DS.Store file on my desktop. everytime i put into the trash it comes back. cannot see where it is associated to. what can i do in order to get it erased from the desktop? thank you.

  • Agent Determination: Responsibilities - No objects found Message no. 5A244

    I'm trying to create a responsibility with Object abbr. MATKL_001, but when I enter I get error message as in subject line.

  • Content Integration Suite : Stand Alone Server mode: Authentication

    I am just getting started trying to understand and CIS. The question that I am trying to answer is: Why is it that when we try to intialize the CIS, we do not pass in any credentials. I have looked at the example and in CheckInFile.java for example,