Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Consuming A .NET Webservice From Java Apache Axis SOAP

2 views
Skip to first unread message

James Kita

unread,
Apr 3, 2002, 11:43:14 AM4/3/02
to
I am having trouble consuming a .NET WebService using Java and Apache Axis
SOAP implementation. My goal is to publish a Web Service consumable from
multiple clients. Here is the issue... I have created an EchoName
WebService that simply echoes the name parameter back. The problem is that
the method input parameter "name" is not getting passed into the method at
all. The .NET Framework indicates that the SOAP Request should be formatted
as follows:

POST /NameWebService/EchoService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/EchoName"

<?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>
<EchoName xmlns="http://tempuri.org/">
<name>string</name>
</EchoName>
</soap:Body>
</soap:Envelope>

The Java Axis client formats the Request as follows:

POST /NameWebService/EchoService.asmx HTTP/1.0

Content-Length: 449

Host: supernova-4

Content-Type: text/xml; charset=utf-8

SOAPAction: "http://tempuri.org/EchoName"

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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:EchoName xmlns:ns1="http://tempuri.org/">
<name xsi:type="xsd:string">Fred</name>
</ns1:EchoName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is exactly the same (if you take into account the XML namespace
changes). But I manually modified the message to be as follows (and it
works):


POST /NameWebService/EchoService.asmx HTTP/1.0

Content-Length: 437

Host: supernova-4

Content-Type: text/xml; charset=utf-8

SOAPAction: "http://tempuri.org/EchoName"

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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>
<!-- remove the namespace tag on EchoName-->
<EchoName xmlns="http://tempuri.org/">
<name xsi:type="xsd:string">Fred</name>
</EchoName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Using this SOAP Request, the .NET WebService works. The only difference is
that Apache Axis added the "ns1" tag to the EchoName which in my mind is
completely acceptable XML formatting of the SOAP message but that confuses
the .NET Framework WebService.

To my eye, this appears to be a bug in the Framework. Any ideas how to get
around this?


Jim


Martin Petersen-Frey

unread,
Apr 3, 2002, 4:59:26 PM4/3/02
to
What does the ASP.NET WebMethod signature look like?

Martin

This posting is provided "AS IS" with no warranties, and confers no rights.

James Kita

unread,
Apr 3, 2002, 5:18:23 PM4/3/02
to
It's very simple...

<WebMethod()> Public Function EchoName(ByVal name As String) As String
EchoName = "Your name is " & name
End Function


"Martin Petersen-Frey" <marty@redmond> wrote in message
news:AZFtjq12BHA.2312@cpmsftngxa10...

Dima Maltsev

unread,
Apr 4, 2002, 3:05:56 PM4/4/02
to
Try to use the following atributes for your web method:

[SoapDocumentMethod(
RequestNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded)
]

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://fssb.myfico.com"
xmlns:types="http://fssb.myfico.com/encodedTypes"

soap:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
g/">
<q1:HelloWorld xsi:type="q1:HelloWorld"
xmlns:q1="http://tempuri.org/">
<str xsi:type="xsd:string">string</str>
</q1:HelloWorld>
</soap:Body>
</soap:Envelope>

Dima

>.
>

James Kita

unread,
Apr 8, 2002, 9:31:13 AM4/8/02
to
This is a step backwards. I get an HTTP 500 error code response.

I may look into it more in the future, but for now, .NET appears to be out
of the question for this application.

Jim

"Dima Maltsev" <dimam...@fairisaac.com> wrote in message
news:570801c1dc14$21897e00$37ef2ecf@TKMSFTNGXA13...

Martin Petersen-Frey

unread,
Apr 8, 2002, 12:11:53 PM4/8/02
to
James,

I'm looking into this. I'll get back to you.

Martin Petersen-Frey

unread,
Apr 8, 2002, 1:07:33 PM4/8/02
to
James,

I took a look at your question. Actually the XML in the SOAP envelope the
Apache client is sending to the Web Service is not correct. When the
Apache client specifies the alias "ns1" for the "http://tempuri.org/"
namespace instead of making it the default namespace for that parameter it
must also add the alias to all child tags that are a part of that
namespace. It didn't do this. If you don't do that, the ASP.NET Web
Service can't indentify the parameter and ignores it. To get the correct
behavior you need to change the SOAP envelope you posted which is:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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:EchoName xmlns:ns1="http://tempuri.org/">
<name xsi:type="xsd:string">Fred</name>
</ns1:EchoName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


To:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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:EchoName xmlns:ns1="http://tempuri.org/">

<ns1:name xsi:type="xsd:string">Fred</ns1:name>


</ns1:EchoName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Note that all I did was to change the <name
xsi:type="xsd:string">Fred<name> tag to
<ns1:name xsi:type="xsd:string">Fred</ns1:name>. The child tags need to
specified as being part of that namespace.

Do that and you'll find that the Web Service works as expected.

Let me know if you have any questions about this.

Martin Petersen-Frey

unread,
Apr 9, 2002, 6:18:55 PM4/9/02
to
Dima,

I just answered the question earlier. The XML in the SOAP envelope the

Apache client is sending to the Web Service is not correct. When the
Apache client specifies the alias "ns1" for the "http://tempuri.org/"
namespace instead of making it the default namespace for that parameter it
must also add the alias to all child tags that are a part of that
namespace. It didn't do this. If you don't do that, the ASP.NET Web

Service can't indentify the parameter and ignores it. Going with SOAP
Encoding, as you suggest, will fix this because namespaces are no longer
needed to identify parameter types but that isn't the root of the
problem. Doc/Literal is the way to go in most cases.

0 new messages