Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > How do you transparently implement the same web service (WSDL) with java axis and .NET ?

Reply
Thread Tools

How do you transparently implement the same web service (WSDL) with java axis and .NET ?

 
 
tomjbr.10216233@bloglines.com
Guest
Posts: n/a
 
      05-11-2005
>If this is the case - isnt it a matter of just using one webservice
>client and changing the URL? Or have I overlooked something?
>I have webservices that are published at multiple locations, and I
>merely change the URL in the client to point them at the right place.
>Im not sure where polymorphism fits into this,


I do not know how you can do it in Delphi, but with Java Axis code, you
are using a client like this:

MyServiceServiceLocator myServiceLocator = new
MyServiceServiceLocator();
MyService_PortType myService = myServiceLocator.getMyService(
new URL("http://localhost:8156/WebServices/MyConcreteService.asmx")
);
String myString = myService.getMyString(); // the polymorphistic
invocation

In the code above, "MyServiceServiceLocator" is a generated class and
"MyService_PortType" is a generated interface.
The generated method "getMyService" instantiates and return a new
object that implement the interface, and this object will take care of
the invocation to the URL specified as parameter.

When creating a C# client, (as described in step 6-8 in my first
message in this thread), the best thing I have been able to come up
with to transparently do invocations to services supporting the same
interface, is to manually create an interface (IMyWebServiceInterface
below) and then create a factory method like this:

IMyWebServiceInterface[] webServiceProxies =
getWebServiceProxys();
foreach(IMyWebServiceInterface webServiceProxy in
webServiceProxies)
{
String myString = webServiceProxy.getMyString(); // the polymorphistic
invocation
}

private IMyWebServiceInterface[] getWebServiceProxys()
{
IMyWebServiceInterface[] webServiceInterfaces = new
IMyWebServiceInterface[2];
webServiceInterfaces[0] = new localhost_java_MyService();
webServiceInterfaces[1] = new localhost_csharpe_MyService();
return webServiceInterfaces;

}

Essentially though, you are right and can consider it as switching URL,
and that would be OK for me, if there would be any methods for just
switching the URL in the generated proxy classes.

/ Tom

 
Reply With Quote
 
 
 
 
tomjbr.10216233@bloglines.com
Guest
Posts: n/a
 
      05-11-2005
Well, I do not believe anymore that the soapAction attribute (within
"wsdlsoapperation" within "wsdl:binding") really has to be a physical
URL, and definitely I do not think it should be the web service URL,
since that one is specified in the wsdlsoap:address element (within
"wsdl:service")

But since .NET was complaining about
"Server did not recognize the value of HTTP Header SOAPAction: ."
I have now tried to generate a soapAction "getMyString" with Java2WSDL,
but eventually ASP.NET will still complain with the message:
"Server did not recognize the value of HTTP Header SOAPAction:
getMyString."

Any concrete suggestions about what I should do to make it work ???

Below I am showing what I have tried to do:

I was now using the parameter "-A OPERATION" to the Java2WSDL as below:

java -cp .;%AXISCLASSPATH% org.apache.axis.wsdl.Java2WSDL -o
myservice.wsdl -l"http://localhost:8083/axis/services/MyService" -A
OPERATION com.myPackage.MyService

The above command will now generate the following WSDL file
myservice.wsdl :
( one difference is: <wsdlsoapperation soapAction="getMyString"/>
instead of an empty string as soapAction value )

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://myPackage.com"
xmlns:impl="http://myPackage.com" xmlns:intf="http://myPackage.com"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<!--WSDL created by Apache Axis version: 1.2
Built on May 03, 2005 (02:20:24 EDT)-->

<wsdl:message name="getMyStringRequest">

</wsdl:message>

<wsdl:message name="getMyStringResponse">

<wsdlart name="getMyStringReturn" type="soapenc:string"/>

</wsdl:message>

<wsdlortType name="MyService">

<wsdlperation name="getMyString">

<wsdl:input name="getMyStringRequest"
message="impl:getMyStringRequest"/>

<wsdlutput name="getMyStringResponse"
message="impl:getMyStringResponse"/>

</wsdlperation>

</wsdlortType>

<wsdl:binding name="MyServiceSoapBinding" type="impl:MyService">

<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdlperation name="getMyString">

<wsdlsoapperation soapAction="getMyString"/>

<wsdl:input name="getMyStringRequest">

<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://myPackage.com"/>

</wsdl:input>

<wsdlutput name="getMyStringResponse">

<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://myPackage.com"/>

</wsdlutput>

</wsdlperation>

</wsdl:binding>

<wsdl:service name="MyServiceService">

<wsdlort name="MyService" binding="impl:MyServiceSoapBinding">

<wsdlsoap:address
location="http://localhost:8083/axis/services/MyService"/>

</wsdlort>

</wsdl:service>

</wsdl:definitions>

Then i generate the java proxy as before from the above WSDL.

I now run the same wsdl.exe command as before, i.e.
wsdl.exe myservice.wsdl /server /namespace:com.myGeneratedPackage
/out:MyService.cs

And it will now generate this code in the class MyService.cs :

namespace com.myGeneratedPackage {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;

/// <remarks/>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MyServiceSoapBinding",
Namespace="http://myPackage.com")]
public abstract class MyServiceService :
System.Web.Services.WebService {

/// <remarks/>
[System.Web.Services.WebMethodAttribute()]

[System.Web.Services.Protocols.SoapRpcMethodAttribu te("getMyString",
RequestNamespace="http://myPackage.com",
ResponseNamespace="http://myPackage.com")]
[return:
System.Xml.Serialization.SoapElementAttribute("get MyStringReturn")]
public abstract string getMyString();
}
}

The only difference from before in "MyService.cs" is :
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("getMyString"
....
instead of as before:
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("" ...

The resulting SOAP request:

POST /WebServices/MyConcreteService.asmx HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related,
text/*
User-Agent: Axis/1.2
Host: 127.0.0.1
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "getMyString"
Content-Length: 378

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getMyString
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://myPackage.com"/>
</soapenv:Body>
</soapenv:Envelope>

Obviously the generated java axis proxy was now changed to set the
SOAPAction.
(when looking in the generated java code I see this statement:
_oper.setSoapAction("getMyString"); )

The resulting SOAP response:

HTTP/1.1 500 Internal Server Error.
Server: Microsoft-IIS/5.1
Date: Wed, 11 May 2005 09:39:12 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server did not recognize the value of HTTP
Header SOAPAction: getMyString.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>

Obviously something is still wrong, so what should I do to make it work
???

/ Tom

 
Reply With Quote
 
 
 
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      05-11-2005
"(E-Mail Removed)" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) oups.com:
> Essentially though, you are right and can consider it as switching URL,
> and that would be OK for me, if there would be any methods for just
> switching the URL in the generated proxy classes.


There is, its really easy:

Admin = new AdminWS.Admin();
if (!aLocal) {
Admin.Url = "https://xxxxxxxx/xxxx.asmx";
}



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
 
Reply With Quote
 
tomjbr.10216233@bloglines.com
Guest
Posts: n/a
 
      05-12-2005
> Essentially though, you are right and can consider it as
> switching URL, and that would be OK for me, if there
> would be any methods for just
> switching the URL in the generated proxy classes.


>There is, its really easy:


>Admin = new AdminWS.Admin();
>if (!aLocal) {
> Admin.Url = "https://xxxxxxxx/xxxx.asmx";
>}


Yes, you are right, that was embarrassingly easy
/ Tom

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
How do you transparently implement the same web service (WSDL) with java axis and .NET ? tomjbr.10216233@bloglines.com Java 0 05-10-2005 12:26 AM
Calling a Web Service using Axis, from within an Axis Web Service running under Tomcat hocho888 Java 1 04-29-2005 08:26 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM



Advertisments