You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Tadashi Fujita <tf...@lsi.nec.co.jp> on 2002/05/27 07:11:41 UTC
Axis beta2 and C# client
Hi, all.
I had a problem Axis beta2 and C# client.
And I could solve the problem by editing C# Stub.
[My Problem]
I deployed "InfoTest" WebService to Axis beta2.
It returns "Info" object. Info has 2 elements,
"ID" and "Name" as String.
| public Info getInfo(String id);
# see following about the detail.
Next, I made C# Stub(TestInfoService.cs) with wsdl.exe in .NET Framework.
| wsdl http://localhost:8080/axis/services/InfoTest?WSDL
And I made C# client using TestInfoService.
| InfoTestService service = new InfoTestService();
| Info info1 = service.getInfo("ID001");
| Console.WriteLine("ID=[" + info1.ID + "] Name=[" + info1.Name + "]");
The expected result is as following.
| ID=[ID001] Name=[Christy]
But I got unexpected result as following.
| ID=[ID001] Name=[]
"ID" was recovered from SOAP message but "Name" is not!
-----------------------------------------------
[My Solution]
I could get an expected result by editing
Info class in InfoTestService.cs.
[original]
| public class Info {
| public string Name;
| public string ID;
| }
[changed]
| public class Info {
| public string name; // "Name" -> "name".
| public string ID;
| }
[result]
| ID=[ID001] Name=[Christy] | It's perfect!
-----------------------------------------------
[My Opinion]
Info class is defined like following in WSDL.
| <complexType name="Info">
| <sequence>
| <element name="Name" nillable="true" type="xsd:string"/> | note!
| <element name="ID" nillable="true" type="xsd:string"/>
| </sequence>
| </complexType>
And Info instance is described like following
in SOAP message Axis returns.
| <multiRef id="id0" SOAP-ENC:root="0" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Info"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/:encodingStyle"
xmlns:ns3="urn:info">
| <name xsi:type="xsd:string">Christy</name> | note!
| <ID xsi:type="xsd:string">ID001</ID>
| </multiRef>
I think Axis should return
| <Name xsi:type="xsd:string">Christy</Name>
not
| <name xsi:type="xsd:string">Christy</name>
because WSDL says "Name", not "name".
Thanks,
Tadashi Fujita
[My envirounment]
Windows2000 Professional
JDK1.4
Tomcat4.0.3
Axis beta2
Visual C#.net standard
----[InfoTest.java(WebService)]----
package info;
public class InfoTest
{
public Info getInfo(String id)
{
String name = null;
if(id.equals("ID001")) {
name = "Christy";
}else if(id.equals("ID002")) {
name = "Nancy";
}else if(id.equals("ID003")) {
name = "Maggie";
}
Info info = new Info();
info.setID(id);
info.setName(name);
return info;
}
}
----[Info.java]----
package info;
public class Info
{
private String m_id = null;
private String m_name = null;
public void setID(String str) {
this.m_id = str;
}
public String getID() {
return this.m_id;
}
public void setName(String str) {
this.m_name = str;
}
public String getName() {
return this.m_name;
}
}
----[deploy.wsdd]----
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="InfoTest" provider="java:RPC">
<parameter name="className" value="info.InfoTest"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:Info" xmlns:myNS="urn:info" languageSpecificType="java:info.Info"/>
</service>
</deployment>
----[WSDL by Axis beta2]----
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:8080/axis/services/InfoTest"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="urn:info"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="http://localhost:8080/axis/services/InfoTest"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://localhost:8080/axis/services/InfoTest-impl"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:info">
<complexType name="Info">
<sequence>
<element name="Name" nillable="true" type="xsd:string"/>
<element name="ID" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<element name="Info" nillable="true" type="tns1:Info"/>
</schema>
</types>
<wsdl:message name="getInfoResponse">
<wsdl:part name="return" type="tns1:Info"/>
</wsdl:message>
<wsdl:message name="getInfoRequest">
<wsdl:part name="in0" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="InfoTest">
<wsdl:operation name="getInfo" parameterOrder="in0">
<wsdl:input message="intf:getInfoRequest"/>
<wsdl:output message="intf:getInfoResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="InfoTestSoapBinding" type="intf:InfoTest">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getInfo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input>
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="getInfo"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/InfoTest"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="InfoTestService">
<wsdl:port name="InfoTest" binding="intf:InfoTestSoapBinding">
<wsdlsoap:address location="http://localhost:8080/axis/services/InfoTest"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
----[C# Stub (generated by "wsdl http://localhost:8080/axis/services/InfoTest?WSDL")]----
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="InfoTestSoapBinding",
Namespace="http://localhost:8070/axis/services/InfoTest")]
public class InfoTestService : System.Web.Services.Protocols.SoapHttpClientProtocol {
public InfoTestService() {
this.Url = "http://localhost:8070/axis/services/InfoTest";
}
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="getInfo",
ResponseNamespace="http://localhost:8070/axis/services/InfoTest")]
[return: System.Xml.Serialization.SoapElementAttribute("return")]
public Info getInfo(string in0) {
object[] results = this.Invoke("getInfo", new object[] {
in0});
return ((Info)(results[0]));
}
public System.IAsyncResult BegingetInfo(string in0, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("getInfo", new object[] {
in0}, callback, asyncState);
}
public Info EndgetInfo(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((Info)(results[0]));
}
}
[System.Xml.Serialization.SoapTypeAttribute("Info", "urn:info")]
public class Info {
public string Name;
public string ID;
}
----[C# client source]----
using System;
namespace InfoTestClient
{
class Class1
{
static void Main(string[] args)
{
InfoTestService service = new InfoTestService();
Info info1 = service.getInfo("ID001");
Console.WriteLine("ID=[" + info1.ID + "] Name=[" + info1.Name + "]");
}
}
}
----[SOAP Request(C# client)]----
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://localhost:8070/axis/services/InfoTest" xmlns:types="http://localhost:8070/axis/services/InfoTest/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1:getInfo xmlns:q1="getInfo">
<in0 xsi:type="xsd:string">ID001</in0>
</q1:getInfo>
</soap:Body>
</soap:Envelope>
----[SOAP Response(Axis beta2)]----
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:getInfoResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="getInfo">
<getInfoReturn href="#id0"/>
</ns1:getInfoResponse>
<multiRef id="id0" SOAP-ENC:root="0" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Info"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/:encodingStyle"
xmlns:ns3="urn:info">
<name xsi:type="xsd:string">Christy</name>
<ID xsi:type="xsd:string">ID001</ID>
</multiRef>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>