This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Getting null value as  response   from .net webservice  when calling from java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Getting null value as  response   from .net webservice  when calling from java client" Watch "Getting null value as  response   from .net webservice  when calling from java client" New topic
Author

Getting null value as response from .net webservice when calling from java client

laxmidhar prad
Ranch Hand

Joined: Feb 05, 2006
Posts: 33
Hi
I am calling .net webservice from java ,it compiles but return null as aresult. Actually what parameter i am sending as argument to .net webservice Here is my code
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.encoding.soapenc.StringDeserializer;
import org.apache.soap.rpc.*;
import org.apache.soap.util.xml.QName;

public class Test_client {

public static void main (String[] args)
throws Exception {

System.out.println("\n\nCalling the SOAP Server to say hello\n\n");
URL url = new URL ("http://153.58.19.96/ASVWS/ASVWS.asmx");
String name = "satya";
Call call = new Call ( );
String s="//";
String p="/";
//call.setTargetObjectURI("xmlns=http:"+s+"tempuri.org"+p);
SOAPMappingRegistry soapMappingRegistry = new SOAPMappingRegistry();
soapMappingRegistry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("http://temp.org/", "HelloWorldResult"),null,null, new StringDeserializer());
call.setTargetObjectURI( "http://temp.org/");
call.setMethodName("HelloWorld");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setSOAPMappingRegistry(soapMappingRegistry);
Vector params = new Vector ( );
params.addElement (new Parameter("name", String.class, name, "http://schemas.xmlsoap.org/soap/encoding/"));
call.setParams (params);

System.out.print("The SOAP Server says: ");

Response resp = call.invoke(url,"http://temp.org/HelloWorld" );

if (resp.generatedFault ( )) {
Fault fault = resp.getFault ( );
System.out.println ("\nOuch, the call failed: ");
System.out.println (" Fault Code = " + fault.getFaultCode());
System.out.println (" Fault String = " + fault.getFaultString ( ));
} else {
System.out.println("Here");
Parameter result = resp.getReturnValue ( );
System.out.print(result.getValue ( ));
System.out.println( );
}
}
}




Here is my wsdl file



<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://tempuri.org/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
<s:element name="GetASVResults_Object">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="branchNumber" type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="accountNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="amount"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="chequeImage" type="s:base64Binary" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBankNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBranchNuber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="sequenceNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="ChequeNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PostingDate" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetASVResults_ObjectResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="GetASVResults_ObjectResult" type="tns:Results" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="Results">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="result"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="rejectreason" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="GetASVResults_AD">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="branchNumber" type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="accountNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="amount"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="chequeImage" type="s:base64Binary" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBankNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBranchNuber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="sequenceNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="ChequeNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PostingDate" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetASVResults_ADResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="GetASVResults_ADResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetASVResults">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="branchNumber" type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="accountNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="amount"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="chequeImage" type="s:base64Binary" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBankNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PresentingBranchNuber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="sequenceNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="ChequeNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="PostingDate" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetASVResultsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="GetASVResultsResult" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="result"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="rejectReasonCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="strExceptionMessage" type="s:string" />
<s:element minOccurs="0" maxOccurs="1"
name="signatureNumber" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a"
type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="b"
type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AddResult"
type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="HelloWorld">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="s"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="HelloWorldResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="GetASVResults_ObjectSoapIn">
<wsdl:part name="parameters"
element="tns:GetASVResults_Object" />
</wsdl:message>
<wsdl:message name="GetASVResults_ObjectSoapOut">
<wsdl:part name="parameters"
element="tns:GetASVResults_ObjectResponse" />
</wsdl:message>
<wsdl:message name="GetASVResults_ADSoapIn">
<wsdl:part name="parameters" element="tns:GetASVResults_AD" />
</wsdl:message>
<wsdl:message name="GetASVResults_ADSoapOut">
<wsdl:part name="parameters"
element="tns:GetASVResults_ADResponse" />
</wsdl:message>
<wsdl:message name="GetASVResultsSoapIn">
<wsdl:part name="parameters" element="tns:GetASVResults" />
</wsdl:message>
<wsdl:message name="GetASVResultsSoapOut">
<wsdl:part name="parameters"
element="tns:GetASVResultsResponse" />
</wsdl:message>
<wsdl:message name="AddSoapIn">
<wsdl:part name="parameters" element="tns:Add" />
</wsdl:message>
<wsdl:message name="AddSoapOut">
<wsdl:part name="parameters" element="tns:AddResponse" />
</wsdl:message>
<wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld" />
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters"
element="tns:HelloWorldResponse" />
</wsdl:message>
<wsdl:portType name="ASVWSSoap">
<wsdlperation name="GetASVResults_Object">
<wsdl:input message="tns:GetASVResults_ObjectSoapIn" />
<wsdlutput message="tns:GetASVResults_ObjectSoapOut" />
</wsdlperation>
<wsdlperation name="GetASVResults_AD">
<wsdl:input message="tns:GetASVResults_ADSoapIn" />
<wsdlutput message="tns:GetASVResults_ADSoapOut" />
</wsdlperation>
<wsdlperation name="GetASVResults">
<wsdl:input message="tns:GetASVResultsSoapIn" />
<wsdlutput message="tns:GetASVResultsSoapOut" />
</wsdlperation>
<wsdlperation name="Add">
<wsdl:input message="tns:AddSoapIn" />
<wsdlutput message="tns:AddSoapOut" />
</wsdlperation>
<wsdlperation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn" />
<wsdlutput message="tns:HelloWorldSoapOut" />
</wsdlperation>
</wsdl:portType>
<wsdl:binding name="ASVWSSoap" type="tns:ASVWSSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdlperation name="GetASVResults_Object">
<soapperation soapAction="http://tempuri.org/GetASVResults_Object"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="GetASVResults_AD">
<soapperation soapAction="http://tempuri.org/GetASVResults_AD"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="GetASVResults">
<soapperation soapAction="http://tempuri.org/GetASVResults"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="Add">
<soapperation soapAction="http://tempuri.org/Add"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="HelloWorld">
<soapperation soapAction="http://tempuri.org/HelloWorld"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="ASVWSSoap12" type="tns:ASVWSSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdlperation name="GetASVResults_Object">
<soap12peration soapAction="http://tempuri.org/GetASVResults_Object"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="GetASVResults_AD">
<soap12peration soapAction="http://tempuri.org/GetASVResults_AD"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="GetASVResults">
<soap12peration soapAction="http://tempuri.org/GetASVResults"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="Add">
<soap12peration soapAction="http://tempuri.org/Add"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
<wsdlperation name="HelloWorld">
<soap12peration soapAction="http://tempuri.org/HelloWorld"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="ASVWS">
<wsdl:port name="ASVWSSoap" binding="tns:ASVWSSoap">
<soap:address location="http://153.58.19.96/ASVWS/ASVWS.asmx" />
</wsdl:port>
<wsdl:port name="ASVWSSoap12" binding="tns:ASVWSSoap12">
<soap12:address location="http://153.58.19.96/ASVWS/ASVWS.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



Please help me out to resolve this issue


Thanks in advance
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Since I am lazy , I will first ask if you have tried to access the .NET web service using soapUI?
If you am able to communicate with the service using soapUI, then you should compare the request messages generated by soapUI and the request messages generated by your Java client.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
 
Don't get me started about those stupid light bulbs.
 
subject: Getting null value as response from .net webservice when calling from java client
 
Similar Threads
access to .net web service
calling a .net web service from server
got error when call to >net webservice from java client
problem calling a remote webservice [ Algo Error]
Empty target namespace with axis1.2