0

I'm having a problem in passing my parameters to a .Net webservice. I'm using axis and java as a client. when I run my java client and debug my webservice at the same time I am able to invoke the webservice but when I check the parameters passed to the .net webservice the value is nothing. what should I do?

Here is my code:

try {
    String endpoint = "http://localhost/Test/Service.asmx?WSDL";
    Service  xxx = new Service();
    Call call = (Call) (xxx.createCall());

    sAcctNo = "test";

    call.setTargetEndpointAddress( new java.net.URL(sEndPoint) );
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY,new Boolean(true));
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY,"http://tempuri.org/GetName");
    call.setOperationName(new QName("GetName"));

    call.setProperty(javax.xml.rpc.Call.OPERATION_STYLE_PROPERTY,"document");

    call.addParameter( new QName("http://tempuri.org","str"),XMLType.XSD_STRING,ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);

    call.setEncodingStyle(null);

    ret = (String) call.invoke( new Object[]{ sAcctNo  } );
    out.println("You passed : '" + ret + "'");

} catch (Exception e) {
    System.err.println(e.toString());
}
Justin
  • 84,773
  • 49
  • 224
  • 367
cyril
  • 71
  • 1
  • 1
  • 7

1 Answers1

0

I think it might be a namespace issue with the operation name.

Try replacing:

call.setOperationName(new QName("GetName"));

with

call.setOperationName(new QName("http://tempuri.org", "GetName"));

Namespace is the first parameter of QName constructor. It might help to debug the SOAP message from a working .NET client and compare to the generated Java client message.

Jordan Owens
  • 692
  • 4
  • 10
  • hi Jordan, thanks for the reply. ive tried ur suggestion but my webservice still doesnt get my passed parameter value. is there any jars i still need to add to make this work.? here's all the jars included.. axis-ant.jar axis.jar commons-discovery-0.2.jar commons-logging-1.0.4.jar jaxrpc.jar log4j-1.2.8.jar saaj.jar wsdl4j-1.5.1.jar – cyril Mar 08 '11 at 04:26
  • I don't think it's a library issue. I believe it's what is referred to as impedance mismatch. I found a thread that that answers the same problem: http://stackoverflow.com/questions/4757741/how-to-call-axis-apache-client-in-java – Jordan Owens Mar 08 '11 at 04:43
  • ive done the same thing with my code. but still getting empty string from the webservice. Is there any way that i would know if my method is 'POST' or 'GET'? does this affect anyway? – cyril Mar 08 '11 at 05:08
  • Use a tool like TCPMon to capture the soap call. It will help you debug the issue. http://ws.apache.org/commons/tcpmon/index.html – Jordan Owens Mar 08 '11 at 14:08
  • Can you tell me how to use WSDL2Java tool in axis? im having problems when i try to run WSDL2Java tool in command prompt. it says, no class definition found. please help me. – cyril Mar 09 '11 at 10:15
  • See http://stackoverflow.com/questions/2299009/wsdl2java-throws-could-not-find-main-class-org-apache-axis-wsdl-wsdl2java – Jordan Owens Mar 10 '11 at 20:56