axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alok Pandey, Noida" <al...@noida.hcltech.com>
Subject Interoperability issues with .NET
Date Fri, 19 Mar 2004 10:33:29 GMT
> Hi,
> 
I am facing an issue in calling my .NET service from an axis soap client. I
have tried both RPC and document techniques available with AXIS. 
With RPC technique I am bound to use primitive datatypes which though is
working fine, But my requirement is to support complex datatypes and 
Objects(XMLNode) for input and output parameters. 

Now the other technique allows me to use all datatypes but when I run my
java client all my input parameters are ignored. 

I have attached below the WebService and the Client code. if anyone has ever
faced such problem pls revert. 

Thanks
Alok



> <WebMethod()> _
>     Public Function Xml_Input1(ByVal objAddr As UserInfo) As String
> 
>         Dim str As String
>         Dim i As Int32
>         Debug.WriteLine(objAddr.Name)
>         Debug.WriteLine(objAddr.Password)
>         Xml_Input1 = "hi"
>     End Function
> 
> Where UserInfo is a public class defined in the webservice.
> 
> Public Class UserInfo
>     Public Name As String
>     Public Password As String
> End Class
> 
> 
> 
> The following SOAP request is generated when I invoke this method.
> 
> POST /epvWebServices/AdvancereportWS.asmx HTTP/1.1
> Host: localhost
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
> SOAPAction: "http://tempuri.org/Xml_Input1"
> 
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>   <soap:Body>
>     <Xml_Input1 xmlns="http://tempuri.org/">
>       <objAddr>
>         <Name>string</Name>
>         <Password>string</Password>
>       </objAddr>
>     </Xml_Input1>
>   </soap:Body>
> </soap:Envelope>
> 
> Now. I can access this webmethod from both .net client as well as the vb
> client. However with the vb client I did some changes in the client code
> while constructing the soap envelope. If you see the SOAP request you will
> see that the namespace "http://tempuri.org/" is there with Xml_Input1 , so
> it means this namespace is attached with all the child elements of
> Xml_Input1 also, which are objAddr, Name and Password.But when I tried to
> access this service from a vb client, the webmethod gets called but the
> objAddr is set to nothing.so i also attached the namespace individually to
> all the child elements also and then i was able to access the values set
> in the object. The vb code is like.
> 
> 
> 
> Public Type UserInfo
>   Name As String
>   Password As String
> End Type
> 
> Public Function VBSoap_Client
> 
>     Dim objAddr As UserInfo
> 
>     objAddr.Name = "Name1"
>     objAddr.Password = "Password1"
> 
>     Dim Serializer As SoapSerializer30
>     Dim Reader As SoapReader30
>     Dim Connector As SoapConnector30
>     Dim b As Boolean
>     Set Connector = New HttpConnector30
>     Connector.Property("AuthUser") = CStr(Trim(Text1.Text))
>     Connector.Property("AuthPassword") = CStr(Trim(Text2.Text))
>     Connector.Property("EndPointURL") = WSDL
>     Connector.Property("WinHTTPAuthScheme") = 1
>     Connector.Connect
>     Connector.Property("SoapAction") = SoapAction
>     
>     Connector.BeginMessage
>     Set Serializer = New SoapSerializer30
>     Serializer.Init Connector.InputStream
>     Serializer.StartEnvelope , "", "UTF-8"
>     Serializer.StartBody "STANDARD"
>     Serializer.StartElement "Xml_Input1", "http://tempuri.org/"
>     Serializer.StartElement "objAddr", "http://tempuri.org/"
>     Serializer.StartElement "Name", "http://tempuri.org/"
>     Serializer.WriteString CStr(objAddr.Name)
>     Serializer.EndElement
>     Serializer.StartElement "Password", "http://tempuri.org/"
>     Serializer.WriteString CStr(objAddr.Password)
>     Serializer.EndElement
>     Serializer.EndElement
>     Serializer.EndElement
>     Serializer.EndBody
>     Serializer.EndEnvelope
>     Connector.EndMessage
> 
> 
> End Function
> 
> 
> Now I have written the java client and need to access this webservice
> using the same input (complex type), the webmethod gets called from the
> client, but then that (objAddr) is set to Nothing when i see the webmethod
> while debugging. I think that i have to individually attach the namespace
> uri "http://tempuri.org/" to every child element of the method as in the
> vb client but in java how to do it? 
> 
> The java client code is here
> 
> 
> import org.w3c.dom.*	;
> import java.io.*;
> import java.util.*;
> import java.net.*;
> import org.apache.soap.util.xml.*;
> import org.apache.soap.*;
> import org.apache.soap.encoding.*;
> import org.apache.soap.encoding.soapenc.*;
> import org.apache.soap.encoding.soapenc.MapSerializer;
> import org.apache.soap.rpc.*;
> import org.apache.soap.transport.http.SOAPHTTPConnection;
> 
> public class testClient {
> 
> 	public static void main(String[] args) throws Exception {
> 
> 		URL url = new URL
> ("http://localhost/epvWebServices/AdvancereportWS.asmx");
> 
> 	      UserInfo objAddr = new UserInfo();
> 		objAddr.Name = "abcfhvf";
> 		objAddr.Password = "toa2";  
> 		
> 	
> 
> 		SOAPMappingRegistry smr = new SOAPMappingRegistry();
> 		MapSerializer mapSer = new MapSerializer();
> 		StringDeserializer sd = new StringDeserializer();
> 
> 		
> 		//QName q = new QName("objAddr","http://tempuri.org/");
> 		
> 		
> 
> 		// create the transport and set parameters
> 		SOAPHTTPConnection st = new SOAPHTTPConnection();
> 
> 		 st.setUserName("administrator"); // this will be your
> machine username
> 	       st.setPassword("itservices");	// this will be your machine
> password
> 
> 		// build the call.
> 		Call call = new Call ();
> 
> 		call.setSOAPTransport(st);
> 		call.setSOAPMappingRegistry (smr);
> 		call.setTargetObjectURI ("http://tempuri.org/");
> 		call.setMethodName("Xml_Input1");
> 	
> call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
> 		
> 		Vector params = new Vector();
> 		params.addElement(new Parameter("Name",
> String.class,objAddr.Name, null));
> 		params.addElement(new Parameter("Name",
> String.class,objAddr.Password, null));
> 		call.setParams(params);
> 		
> 	  
> 		Response resp = null;
> 		try {
> 		  resp = call.invoke(url, "http://tempuri.org/Xml_Input1");
> 		}
> 		catch (SOAPException e) {
> 			System.err.println("Caught SOAPException (" +
> e.getFaultCode () + "): " + e.getMessage ());
> 			return;
> 		}
> 		 if (resp != null && !resp.generatedFault()) {
> 		   Parameter ret = resp.getReturnValue();
> 		  Object value = ret.getValue();
> 
> 		  System.out.println ("Answer-->  " + value);
> 		}
> 		else {
> 			Fault fault = resp.getFault ();
> 			System.err.println ("Generated fault: ");
> 			System.out.println (" Fault Code = " +
> fault.getFaultCode());
> 			System.out.println (" Fault String = " +
> fault.getFaultString());
> 		}
> 	}
> }
> 
> class UserInfo
> {
> public String Name, Password;
> 
> 	UserInfo()
> 	{Name= "abc";
> 	 Password="123";
> 	}
> 
> UserInfo (String aa, String bb)
> 	{
> 	Name= aa;
> 	Password = bb;
> }
> 
> 
> };
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 

Mime
View raw message