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;

Similar Messages

  • Non-varargs call of varargs method with inexact argument type for last para

    i have no idea what the error:
    non-varargs call of varargs method with inexact argument type for last parameter
    means.
    return (Component)sceneClass.getConstructor(
    new Class[]{int.class, int.class}).newInstance(
         new Integer[]{new Integer((int)sceneDimension.getWidth()),
                new Integer((int)sceneDimension.getHeight())});
    this is the problem area but i'm not sure how to get around it..
    any help would be appreciated

    I am a Java learner and I got the same warning. My code runs like this:
    import java.lang.reflect.*;
    class Reflec
         public static void main(String[] args)
              if(args.length!=1)
                   return;
              try
                   Class c=Class.forName(args[0]);
                   Constructor[] cons=c.getDeclaredConstructors();
                   Class[] params=cons[0].getParameterTypes();
                   Object[] paramValues=new Object[params.length];
                   for(int i=0; i<params.length; i++)
                        if(params.isPrimitive())
                             paramValues[i]=new Integer(i+3);
                   Object o=cons[0].newInstance(paramValues);
                   Method[] ms=c.getDeclaredMethods();
                   ms[0].invoke(o, null);
              catch(Exception e)
                   e.printStackTrace();
    class Point
         static
              System.out.println("Point class file loaded and an object Point generated£¡");     
         int x, y;
         void output()
              System.out.println("x="+x+"\ny="+y);
         Point(int x, int y)
              this.x=x;
              this.y=y;
    When I compiled the file I got the following:
    Reflec.java:26: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    cast to java.lang.Object for a varargs call
    cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    ms[0].invoke(o, null);
    ^
    1 warning
    Since the problem was with this line "ms[0].invoke(o, null);" and the specific point falls on the last argument as the warning mentioned that " ... method with inexact argument type for last parameter", I simply deleted the argument "null" and the line becomes "ms[0].invoke(o);" and it works, no warning anymore!
    DJ Guo from Xanadu
    Edited by: Forget_Me_Not on Jan 8, 2009 10:39 AM

  • A question about a method with generic bounded type parameter

    Hello everybody,
    Sorry, if I ask a question which seems basic, but
    I'm new to generic types. My problem is about a method
    with a bounded type parameter. Consider the following
    situation:
    abstract class A{     }
    class B extends A{     }
    abstract class C
         public abstract <T extends A>  T  someMethod();
    public class Test extends C
         public <T extends A>  T  someMethod()
              return new B();
    }What I want to do inside the method someMethod in the class Test, is to
    return an instance of the class B.
    Normally, I'm supposed to be able to do that, because an instance of
    B is also an instance of A (because B extends A).
    However I cannot compile this program, and here is the error message:
    Test.java:16: incompatible types
    found   : B
    required: T
                    return new B();
                           ^
    1 errorany idea?
    many thanks,

    Hello again,
    First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
    and I understood that in fact, as spoon_ says the only returned value can be null.
    I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
    I have been working with cryptography API Core in Java. I understood that there are classes and
    interfaces for defining keys and key factories specification, such as KeySpec (interface) and
    KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
    understand them better. So I created a class implementing the interface KeySpec, following by a
    corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
    compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
    for my classes, I saw for the first time this strange method header:
    protected abstract <T extends KeySpec> T engineGetKeySpec
    (Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
    in order to not to open a complicated security discussion but just to explain the ambiguous
    part for me, that is, the use of T generic parameter.
    The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
    providers, the possibility to implement cryptography services and algorithms according to a given
    RFC (or whatever technical document). The methods in this class are invoked inside the
    KeyFactory class (If you have installed the JDK sources provided by Sun, You can
    verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
    key specification, that is, a class that implements the interface KeySpec and this class is often
    defined by the provider and not Sun.
    stefan.schulz wrote:
    >
    If you define the method to return some bound T that extends A, you cannot
    return a B, because T would be declared externally at invocation time.
    The definition of T as is does not make sense at all.>
    He is absolutely right about that, but the problem is, as I said, here we are
    talking about the implementation and not the invocation. The implementation is done
    by the provider whereas the invocation is done by Sun in the class KeyFactory.
    So there are completely separated.
    Therefore I wonder, how a provider can finally impelment this method??
    Besides, dannyyates wrote
    >
    Find whoever wrote the signature and shoot them. Then rewrite their code.
    Actually, before you shoot them, ask them what they were trying to achieve that
    is different from my first suggestion!
    >
    As I said, I didn't choose this method header and I'm completely agree
    with your suggestion, the following method header will do the job very well
    protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
    throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
    in this method header definition.
    Once agin, thanks a lot for the answers.

  • Call a method with complex data type from a DLL file

    Hi,
    I have a win32 API with a dll file, and I am trying to call some methods from it in the labview. To do this, I used the import library wizard, and everything is working as expected. The only problem which I have is with a method with complex data type as return type (a vector). According to this link, import library wizard can not import methods with complex data type.
    The name of this method is this:   const std::vector< BlackfinInterfaces::Count > Counts ()
    where Count is a structure defined as below:
    struct Count
       Count() : countTime(0) {}
       std::vector<unsigned long> countLines;
       time_t countTime;
    It seems that I should manually use the Call Library Function Node. How can I configure parameters for the above method?

    You cannot configure Call Library Function Node to call this function.  LabVIEW has no way to pass a C++ class such as vector to a DLL.

  • Error when calling method with a return of double in j2me

    hello all,
    i have following problem with a j2me program:
    if i call a method with a return of double, then i get following error
    message:
    ERROR: floating-point constants should not appear
    Error preverifying class test.hallo
    what i'm doing wrong
    thanks in regard
    ----------------example----------------------------
    double yourValue(int y, int m, int d)
    double v = 0.10;
    v = 3.39 y m *d
    return v;
    public void startApp()
    int td;
    int y =2;
    int m =2;
    int d =2;
    td = yourValue(y,m,d);
    return(td);

    It's true for MIDP 1.0.
    But you can always use implementation of the float
    point arithmetic which was written by independent
    developers. For example see J2ME section of my
    homepage http://henson.newmail.ru
    anyway, double is reserved word in java, the way you wrote the source code in your example neither the preverifier nor the compiler will recognize that you intend to use your own types for double and float. maybe with Double or Float it would be different ...
    further question: you declare a void function, in the body, however, you try to return some value. something wrong with this function??
    regards
    bernard

  • 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.

  • EJB3 Creating Web Services with Complex Return Types

    Hi
    Not sure if this is the right place, but hoping someone can help!
    I have an entity bean that has a collection (list<Address>) of sub-entities. I have then created a session bean to retrieve the Business and populate it's children.
    I then expose this as a web service and although it works and I get appropriate XML out, the WSDL of the deployed service is not as I would like.
    For example:
    The return type is
    <complextype name="Business">
    <sequence>
    <element name="id" type="int"/>
    <element name="addresses" type="ns1:list"/>
    </sequence>
    </complextype>
    <complextype name="Address">
    <sequence>
    <element name="id" type="int"/>
    <element name="addresses1" type="string"/>
    <element name="addresses2" type="string"/>
    <element name="addresses3" type="string"/>
    </sequence>
    </complextype>
    ns1:list is included as a separate schema as a complex extension of the base "collection"
    So, even though the Address type is there it is not referenced from Business.
    So, when I'm calling the Web Service from BPEL or ESB, I have not got the ability to map adequately back from the response.
    I have tried a whole bunch of ways of getting this to work, but so far to no avail...
    Has anyone seen this before, or can I somehow override the mapping from the Entity to the WSDL?
    Any help would be most appreciated.
    Thanks
    Chris

    Thanks. We are using a Java Proxy to consume the web service as we need to use JAX-WS handlers. We created data control from the service stub that was created by the proxy. Our issue is with the response XML which comes as a complex type. Also, the data control is understanding the complex type and is creating the structure right. The problem is when we drag that control on a JSF page. No data is displayed. We think that we are not traversing the complex object properly which is creating the issue.
    I understand that you answer related to the input is applicable to output as well. We can change the structure by flattening it but we thought that in 11G there is some new features where we can use the complex types out of the box without any change. Is that true? Also, any luck in finding the documents (broken links) on your blog page?

  • 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

  • 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.

  • Problems with document return type

    Hi, i've deployed a web service in weblogic 6.1 that returns a xml document. When
    i try to execute the client, i receive this error message:
    ------------- RECEIVING XML -------------
    <?xml version="1.0"?>
    <definitions
    targetNamespace="java:examples.webservices.rpcXML.pruebaXML"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="java:examples.webservices.rpcXML.pruebaXML"
    xmlns:dom="http://www.w3c.org/1999/DOM"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    >
    <types>
    <schema targetNamespace='java:examples.webservices.rpcXML.pruebaXML'
    xmlns='http://www.w3.org/1999/XMLSchema'>
    </schema>
    </types>
    <message name="getXMLRequest">
    </message>
    <message name="getXMLResponse">
    <part name="return" type="dom:org.w3c.dom.Document" />
    </message>
    <portType name="PruebaXMLPortType">
    <operation name="getXML">
    <input message="tns:getXMLRequest"/>
    <output message="tns:getXMLResponse"/>
    </operation>
    </portType>
    <binding name="PruebaXMLBinding" type="tns:PruebaXMLPortType"><soap:binding style="rpc"
    transport="http://schemas.xmlsoap.org/soap/http/"/>
    <operation name="getXML">
    <soap:operation soapAction="urn:getXML"/>
    <input><soap:body use="encoded" namespace='urn:PruebaXML' encodingStyle="http://xml.apache.org/xml-soap/literalxml
    http://schemas.xmlsoap.org/soap/encoding/"/></input>
    <output><soap:body use="encoded" namespace='urn:PruebaXML' encodingStyle="http://xml.apache.org/xml-soap/literalxml
    http://schemas.xmlsoap.org/soap/encoding/"/></output>
    </operation>
    </binding>
    <service name="PruebaXML"><documentation>todo</documentation><port name="PruebaXMLPort"
    binding="tns:PruebaXMLBinding"><soap:address location="http://localhost:7001/pruebaXML/pruebaXMLuri"/></port></service></definitions>
    ===================================================================================
    ERROR =================================================================
    javax.naming.NamingException: i/o failed java.io.IOException: http://xml.apache.org/xml-soap/literalxml
    http://schemas.xmlsoap.org/soap/encoding/:http://www.w3c.org/1999/DOM:org.w3c.dom.Document:No
    codec for decoding http://xml.apache.org/xml-soap/literalxml: [ CodecFactory:
    http://schemas.xmlsoap.org/soap/encoding/=null, =null]. Root exception is java.io.IOException:
    http://xml.apache.org/xml-soap/literalxml http://schemas.xmlsoap.org/soap/encoding/:http://www.w3c.org/1999/DOM:org.w3c.dom.Document:No
    codec for decoding http://xml.apache.org/xml-soap/literalxml: [ CodecFactory:
    http://schemas.xmlsoap.org/soap/encoding/=null, =null]
         at weblogic.soap.wsdl.binding.Part.typeToClass(Part.java:74)
         at weblogic.soap.wsdl.binding.Part.toSoapType(Part.java:51)
         at weblogic.soap.wsdl.binding.Message.getReturnType(Message.java:58)
         at weblogic.soap.wsdl.binding.BindingOperation.populate(BindingOperation.java:52)
         at weblogic.soap.wsdl.binding.Binding.populate(Binding.java:48)
         at weblogic.soap.wsdl.binding.Definition.populate(Definition.java:116)
         at weblogic.soap.WebServiceProxy.getServiceAt(WebServiceProxy.java:176)
         at weblogic.soap.http.SoapContext.lookup(SoapContext.java:76)
         at javax.naming.InitialContext.lookup(InitialContext.java:350)
         at examples.webservices.rpcXML.javaClient.Client.main(Client.java:40)
    Exception in thread "main"
    This is the wsdl file that weblogic generates:
    <?xml version="1.0" ?>
    - <definitions targetNamespace="java:examples.webservices.rpcXML.pruebaXML" xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="java:examples.webservices.rpcXML.pruebaXML" xmlns:dom="http://www.w3c.org/1999/DOM"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    - <types>
    <schema targetNamespace="java:examples.webservices.rpcXML.pruebaXML" xmlns="http://www.w3.org/1999/XMLSchema"
    />
    </types>
    <message name="getXMLRequest" />
    - <message name="getXMLResponse">
    <part name="return" type="dom:org.w3c.dom.Document" />
    </message>
    - <portType name="PruebaXMLPortType">
    - <operation name="getXML">
    <input message="tns:getXMLRequest" />
    <output message="tns:getXMLResponse" />
    </operation>
    </portType>
    - <binding name="PruebaXMLBinding" type="tns:PruebaXMLPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http/"
    />
    - <operation name="getXML">
    <soap:operation soapAction="urn:getXML" />
    - <input>
    <soap:body use="encoded" namespace="urn:PruebaXML" encodingStyle="http://xml.apache.org/xml-soap/literalxml
    http://schemas.xmlsoap.org/soap/encoding/" />
    </input>
    - <output>
    <soap:body use="encoded" namespace="urn:PruebaXML" encodingStyle="http://xml.apache.org/xml-soap/literalxml
    http://schemas.xmlsoap.org/soap/encoding/" />
    </output>
    </operation>
    </binding>
    - <service name="PruebaXML">
    <documentation>todo</documentation>
    - <port name="PruebaXMLPort" binding="tns:PruebaXMLBinding">
    <soap:address location="http://carlos-3-116:7001/pruebaXML/pruebaXMLuri" />
    </port>
    </service>
    </definitions>
    Could anyone help me, thanks

    Here is a the actual php class:
    class question{
    function getQuestionDetails()
    $r = array("r"=>"s","t"=>11230,"wr"=>500);
    return $r;
    This class has a defined return VO(questionDetails) in flex. It is recognized in the IDE, but when I run the app, I always get a "null object reference" error. I can't seem to convert the result to questionDetails, and I can't access the fields as properties or part of an array of the return object as an instance of "Object".
    Any ideas?
    Thanks!

  • Publish ColdFusion Web Service with Complex Return Type

    Hi,
    I am working on a project to publish couple ColdFusion
    webservices. The cosumer of those webservices is a Java
    application.
    One of my webservice need return an object. Here are demo
    codes:
    The returned ojbect is AddressRespond
    AddressRespond.cfc:
    <cfcomponent>
    <cfproperty name="addresses" type="Address[]" />
    <cfproperty name="myLearnException" type="MyException"
    />
    </cfcomponent>
    Address.cfc:
    <cfcomponent>
    <cfproperty name="city" type="string" />
    <cfproperty name="state" type="string" />
    </cfcomponent>
    MyException.cfc:
    <cfcomponent>
    <cfproperty name="code" type="string" />
    <cfproperty name="reason" type="string" />
    </cfcomponent>
    If the webservice "cosumer" is a ColdFusion application,
    there is no any problems. But the Java application doesn't
    understand the type of addresses in the WSDL file which is
    gernerated by ColdFusion:
    <complexType name="Address">
    <sequence>
    <element name="city" nillable="true"
    type="xsd:string"/>
    <element name="state" nillable="true"
    type="xsd:string"/>
    </sequence>
    </complexType>
    <complexType name="MyException">
    <sequence>
    <element name="code" nillable="true"
    type="xsd:string"/>
    <element name="reason" nillable="true"
    type="xsd:string"/>
    </sequence>
    </complexType>
    <complexType name="AddressRespond">
    <sequence>
    <element name="addresses" nillable="true"
    type="tns1:ArrayOf_xsd_anyType"/>
    <element name="MyException" nillable="true"
    type="impl:MyException"/>
    </sequence>
    </complexType>
    Could anybody give me any idea on how to resolve this
    problem?
    Thanks!

    The web service is actually the function, not the cfc and you
    didn't show a function.
    My own opinion is that since webservices by definition should
    be available to any calling app (cold fusion, .net, flash, etc),
    whatever gets returned from the method should be as universally
    recognizable as possible. This generally means text, numbers,
    boolean, or xml.

  • Urgent please ! How to invoke java method with diffrent argument types?

    Hi,
    I am new to JNI.
    I had gone through documentation but it is not of much help.
    Can any one help me out how to invoke the below java method,
    // Java class file
    public class JavaClassFile
    public int myJavaMethod(String[] strArray, MyClass[] myClassArray, long time, int[] ids)
    // implementation of method
    return 0;
    // C++ file with Invokation API and invokes the myJavaMethod Java method
    int main()
    jclass cls_str = env->FindClass("java/lang/String");
    jclass cls_MyClass = env->FindClass("MyClass");
    long myLong = 2332323232;
    int intArray[] = {232, 323, 32, 77 };
    jclass cls_JavaClassFile = env->FindClass("JavaClassFile");
    jmethodID mid_myJavaMethod = env->GetMethodID( cls_JavaClassFile, "myJavaMethod", "([Ljava/lang/String;[LMyClass;J[I)I");
    // invoking the java method
    //jint returnValue = env->CallIntMethod( cls_JavaClassFile, mid_myJavaMethod, stringArray, myClassArray, myLong, intArray ); --- (1)
    //jint returnValue = env->CallIntMethodA( cls_JavaClassFile, mid_myJavaMethod, ...........); --- (2)
    //jint returnValue = env->CallIntMethodV( cls_JavaClassFile, mid_myJavaMethod, ...........); --- (3)
    Can any one tell me what is the correct way of invoking the above Java method of (1), (2) and (3) and how ?
    The statement (1) is compilable but throws error at runtime, why ?
    How can I use statements (2) and (3) over here ?
    Thanks for any sort help.
    warm and best regards.

    You are missing some steps.
    When you invoke a java method from C++, the parameters have to be java parameters, no C++ parameters.
    For example, your code appears to me as thogh it is trying to pass a (C++) array of ints into a java method. No can do.
    You have to construct a java in array and fill it in with values.
    Here's a code snippet:
    jintArray intArray = env->NewIntArray(10); // Ten elments
    There are also jni functions for getting and setting array "regions".
    If you are going to really do this stuff, I suggest a resource:
    essential JNI by Rob Gordon
    There is a chapter devoted to arrays and strings.

  • Consuming Java Web Service with complex return types

    Hi,
    I'm consuming a Java Web Service and the return I get in
    ColdFusion is a typed Java Object (with custom Java classes like
    com.company.project.JavaClass ...)
    Within this object I don't get direct accessible properties
    as when I'm consuming ColdFusion Web Services, instead I get a
    getPROPERTYNAME and setPROPERTYNAME method for each property.
    How can I handle this? I don't want to call this methods for
    each property (and there are nested objects with arrays of custom
    classes below, which would really make this complicated).
    What's the best way to cope up with this?
    Thanks a lot,
    Fritz

    The web service is actually the function, not the cfc and you
    didn't show a function.
    My own opinion is that since webservices by definition should
    be available to any calling app (cold fusion, .net, flash, etc),
    whatever gets returned from the method should be as universally
    recognizable as possible. This generally means text, numbers,
    boolean, or xml.

  • Asking for return type with constructor

    import java.swing.*;
    public class firstWindow extends JFrame
         public static final int WIDTH = 300;
         public static final int HEIGHT = 200;
         public FirstWindow()
              super();
              setSize(WIDTH,HEIGHT);
              JLabel newLabel = new JLabel("My Medical Record.");
              getContentPane().add(newLabel);
              WindowDestroyer listener = new WindowDestroyer();
              addWindowListener(listener);
    }Continue to get a 'method with no return type'. I looked for a syntax error but can't see it.
    Edited by: Zarnon on Mar 2, 2008 2:07 PM

    radiorx wrote:
    public FirstWindow()Class name is firstWindow, so the constructor should be re-named :
    public firstWindow()In the former case, the FirstWindow identifier creates a method rather than a constructor, and methods in Java need a return type.
    Hope this helpsInstead of renaming the constructor, rename the class file public class firstWindow extends JFrame into public class FirstWindow extends JFrame

  • Covariant return types without "-source 1.5"

    Hello all,
    I've just noticed that one can compile code that makes use of covariant return types even without specifying the flag -source 1.5.
    Just out of curiosity: Was that behvaiour of javac intentional?
    What's more, if you compile it with target 1.4
    you can even run it with a 1.4 JRE!
    Great, ain't it?

    I've just noticed that one can compile code thatmakes use of covariant return types even without
    specifying
    the flag -source 1.5.
    Very interesting, actually it runs on jdk 1.3.1 too.
    Actually using -target 1.4 or -target 1.3 generated the sameclass file in a small example (with the exception of the version number). And this class file contains 2 method entry per covariant(ed) method. One method with the return type specified in the source code and a second method with the return type of the base class. The second method is of synthetic and has a virtual call to the the this method.
    with -target 1.5 you also get both method entries, but the second one is not synthetic anymore (??).

Maybe you are looking for

  • NI-DAQmx 8.5 Installer (Download version) hangs asking for Disk 2

    My configuration:LabVIEW 8.2.1, WindowsXP SP2 Using the downloaded version of NI-DAQ (NIDAQ850.exe). I'm trying to install NI-DAQmx 8.5 on a clean LabVIEW build machine. The installer hangs prompting me to insert CD disk 2. It states "The specfied fo

  • N95 Mind of it's own!

    I have an N95 which has suddenly started doing it's own thing. It started with it turning itself off and on, then randomly ringing people. It is now impossible to turn the phone on without it going crazy, I switch it on then all it does is go through

  • Mail 4.2: Different accounts - pw protection possible?

    Hello! I would like to protect my personal "Mail"-email-account and another account) with two different "master passwords" (so you'll have to enter the password before the inboxes open). Is that possible and if so: how? Thanks in advance!

  • Essbase unix file system best practice

    Is there such thing in essbase as storing files in different file system to avoid i/o contention? Like for example in Oracle, it is best practice to store index files and data files indifferent location to avoid i/o contention. If everything in essba

  • App store fails to launch

    Since I upgraded to Mavericks I can't launch the app store.  It comes up with a blank page and freezes, force quitting does not help.  I can't find a place to download a new version.  Any thoughts?