You are right. And it is due to my
clumsiness that I didn't understand that the WSDL2Java tool would do the job.
I appreciate the advice.
Luckily for me I guess, it seems now that the web services returning an array are not the ones I have to implement in my Java Client.
Unluckily however that it also seems I ran into a known problem when using Java clients to call a .Net web service.
The problem involves that a .NET web service doesn't implicitly support data type definitions for each return parameter and that a Java client will fail (.Net client succeeds) if a certain line of code is not added to a .Net web service.
That line of code seems to be something like :
<SoapRpcMethod(Action:=<soapAction url>,RequestNamespace:="<req nmspace>",ResponseNamespace:="<res nmspace>"),WebMethod()>
I got this info from a thread on the java sun forum (http://forum.java.sun.com/thread.jsp?thread=386360&forum=331&message=1661636).
In there, a reference to an article is given (http://www.codenotes.com/articles/articleAction.aspx?articleID=541), wich explains how to invoke calls on .Net web services from any client and when you look at the web service example code, the line of code mentioned above is present.
My problem is that I am not in control of the web service development. Some company wrote them and gave me the url of the WSDL.
So I guess I'll have to ask them to make a minor change in their source code.
However, I took a peep in their .Net source code and there is a line of code wich ressembles (but not matches) the soapRpcMethod.
But, I don't know a thing about .Net so it's a bit of chinese to me.
So I'm wondering if anyone out there either knows about the problem just mentioned and knows by looking at the source code below if the line put in bold would have the same functionality as soapRpcMethod.
Because If it does, that would mean the problem would reside in my Java client code. Wich seems unlikely to me, because everything works uptill the response results wich differ from the expected ones (I receive wrong response values such as -1, -10, etc.).
=======================
.Net Web services server code
=======================
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
...
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(<soapAction url>, RequestNamespace=<req namespace>, ResponseNamespace=<res namespace>, Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int CheckCustomer(string customerReference) {
object[] results = this.Invoke("CheckCustomer", new object[] {customerReference});
return ((int)(results[0]));
I appreciate the advice.
Luckily for me I guess, it seems now that the web services returning an array are not the ones I have to implement in my Java Client.
Unluckily however that it also seems I ran into a known problem when using Java clients to call a .Net web service.
The problem involves that a .NET web service doesn't implicitly support data type definitions for each return parameter and that a Java client will fail (.Net client succeeds) if a certain line of code is not added to a .Net web service.
That line of code seems to be something like :
<SoapRpcMethod(Action:=<soapAction url>,RequestNamespace:="<req nmspace>",ResponseNamespace:="<res nmspace>"),WebMethod()>
I got this info from a thread on the java sun forum (http://forum.java.sun.com/thread.jsp?thread=386360&forum=331&message=1661636).
In there, a reference to an article is given (http://www.codenotes.com/articles/articleAction.aspx?articleID=541), wich explains how to invoke calls on .Net web services from any client and when you look at the web service example code, the line of code mentioned above is present.
My problem is that I am not in control of the web service development. Some company wrote them and gave me the url of the WSDL.
So I guess I'll have to ask them to make a minor change in their source code.
However, I took a peep in their .Net source code and there is a line of code wich ressembles (but not matches) the soapRpcMethod.
But, I don't know a thing about .Net so it's a bit of chinese to me.
So I'm wondering if anyone out there either knows about the problem just mentioned and knows by looking at the source code below if the line put in bold would have the same functionality as soapRpcMethod.
Because If it does, that would mean the problem would reside in my Java client code. Wich seems unlikely to me, because everything works uptill the response results wich differ from the expected ones (I receive wrong response values such as -1, -10, etc.).
=======================
.Net Web services server code
=======================
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
...
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(<soapAction url>, RequestNamespace=<req namespace>, ResponseNamespace=<res namespace>, Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int CheckCustomer(string customerReference) {
object[] results = this.Invoke("CheckCustomer", new object[] {customerReference});
return ((int)(results[0]));
}
...
To be sure the whole picture is given, I add my updated Java client code :
============
Java
Client code
============
...
Call call = (Call) new Service().createCall();
call.setTargetEndpointAddress( new URL(endpoint) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionUri + operationName);
...
Call call = (Call) new Service().createCall();
call.setTargetEndpointAddress( new URL(endpoint) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionUri + operationName);
call.setOperationName( new
QName(soapActionUri, operationName) );
String customerReference = (String) parameters.get("customerReference");
call.addParameter("customerReference", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType( XMLType.XSD_INT);
Integer i = (Integer) call.invoke( new Object[] { customerReference } );
String customerReference = (String) parameters.get("customerReference");
call.addParameter("customerReference", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType( XMLType.XSD_INT);
Integer i = (Integer) call.invoke( new Object[] { customerReference } );
...
Nothing fails, but the output of the variable i = -1, while it should be another value.
And that problem seems to match the problems mentioned in the thread (1st url) I mentioned above.
So I guess I'm hoping that one of you can either confirm this problem, so I can ask that they change their source code a bit, or that I'm wrong. But in that case, I'd like to know where I'm wrong :D
I know this is a whole explanation, but I'm hoping it's worth the effort replying.
Kind regards, and again thx for the help earlier on the client stubs !
Nothing fails, but the output of the variable i = -1, while it should be another value.
And that problem seems to match the problems mentioned in the thread (1st url) I mentioned above.
So I guess I'm hoping that one of you can either confirm this problem, so I can ask that they change their source code a bit, or that I'm wrong. But in that case, I'd like to know where I'm wrong :D
I know this is a whole explanation, but I'm hoping it's worth the effort replying.
Kind regards, and again thx for the help earlier on the client stubs !
-----Original Message-----
From: Sherman, Dennis (END-CHI) [mailto:[EMAIL PROTECTED]
Sent: 11 February 2004 15:07
To: '[EMAIL PROTECTED]'
Subject: RE: client calling service that returns array possible ?Is there some reason you're not using the WSDL2Java tool that generates client stubs for you? The code it generates will manage all of the call.set*(), QName creation, type mappings, and so on for you.--
Dennis R. Sherman
Endeavor Information Systems
847-227-2976
[EMAIL PROTECTED]
http://www.endinfosys.com-----Original Message-----
From: Quinten Verheyen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 11, 2004 3:10 AM
To: Axis-User (E-mail)
Subject: FW: client calling service that returns array possible ?In addition I add my code for the Client class :
Service service = new Service();Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setProperty(call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(call.SOAPACTION_URI_PROPERTY, "soapactionUri");
call.setOperationName( "operationName" );// From now on I'm guessing ...
// I assume I should provide the name of a local classQName qn = new QName( "CustomContainer" );// Register the type mapping, because I receive "<string>string</string><string>string</string>" as a response I use the
// Array (de)serializer classescall.registerTypeMapping(CustomContainer.class, qn, new ArraySerializerFactory(), new ArrayDeserializerFactory() );// set the QName class as a return type
call.setReturnType( qn );// Invoking the method is no problem (invokeOneWay works), catching the result properly however ..
Object results = call.invoke( new Object[] {} );
ArrayList test = (ArrayList) results; // casting to ArrayList is just a guess, but it worksfor (int i = 0; i < test.size(); i++) {
System.out.println( (String) test.get(i) );
}
The output is of the for loop is :
250ad245-6940-4b47-b474-6f2289ce15c1
e32df6d3-5999-47ce-9283-709719d7ae8a
c4a38157-706e-4ac1-a181-b90c1f9378e1The problem is .. I don't know what QName class I should provide, it doesn't matter if I provide an existing class (e.g. String.class) or a custom one. The output remains the same.
And also I don't know what the return type of the invoked call is. I guessed that an ArrayList does the job, but the output isn't readable.
Again, I didn't write the services, they just gave me a URL to the WSDL.
Any help or advice at all is very much needed and appreciated :-)-----Original Message-----
From: Quinten Verheyen
Sent: 10 February 2004 20:17
To: '[EMAIL PROTECTED]'
Subject: client calling service that returns array possible ?Hi,
I am new to Axis so if my question seems repetitive, my apologies.
I have to write a client that can call WSDL services.
Most of the services return an int, wich should pose no problem (= call.setReturnType(XMLType.XSD_INT) ).However, I am stuck when I see this :HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?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> <ResponseName xmlns="url"> <methodName> <string>string</string> <string>string</string> </methodName> </ResponseName> </soap:Body> </soap:Envelope>The method name returns an array of strings (I assume) instead of a string.
I don't know what the return type is in this case.
No matter what I try, I get a (logical) error :org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.Expected I guess, but that doesn't give me any clue about how to solve this problem.Sure I saw a couple of threads and mails about using custom (de)serializers etc. BUT I am only using that WDSL, I didn't develop it, so I cannot write
custom beans because they wouldn't be recognized. At least, that's how I understood it.I sure would appreciate the help, cause this thing needs to be solved quite quickly ..Verheyen Quinten
Software EngineerRue Gabrielle Petitstraat 4/61080 BrusselTel : +0032 (0)2 502 85 00Fax : +0032 (0)2 502 76 07
Gsm : +0032 (0)494 81 04 81E-mail : [EMAIL PROTECTED]
Politicians' Syllogism :
step 1 : we must do something.
step 2 : this is something.
step 3 : therefore we must do it.
