SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : XML Technologies :

Previous DiscussionNext Discussion
 call .net web services with java

hi. i have a web service .net and try to call this from java. This is the code.

String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
URL url = null;
try {
url = new URL("http://10.1.12.234/pruebaWebService/Service1.asmx");
} catch (MalformedURLException e1) {
e1.printStackTrace();
}


SOAPMappingRegistry soapMappingRegistry = new SOAPMappingRegistry();
soapMappingRegistry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("", "return"),null, null, new StringDeserializer());



// Build the call.
Call call = new Call();
call.setSOAPMappingRegistry(soapMappingRegistry);
call.setTargetObjectURI("http://tempuri.org/");
call.setMethodName("HelloWorld");
call.setEncodingStyleURI(encodingStyleURI);

Vector params = new Vector();

params.addElement(new Parameter("pSXml", String.class, "hola", null));
params.addElement(new Parameter("pSNombre", String.class, "tal", null));
call.setParams(params);

// Invoke the call.
Response resp = null;

try {
resp = call.invoke(url, "http://tempuri.org/HelloWorld");
} catch (SOAPException e) {
System.err.println("Caught SOAPException ("+ e.getFaultCode()+ "): "+ e.getMessage());
}

AND THE ERROR IS:

Caught SOAPException (SOAP-ENV:Client): No Deserializer found to deserialize a 'http://tempuri.org/:HelloWorldResult' using encoding style 'null'.


THIS IS THE GET AND POST WHEN I CALL THIS FROM INTERNET EXPLORER:

GET /pruebaWebService/Service1.asmx/HelloWorld?pSXml=string&pSNombre=string HTTP/1.1
Host: 10.1.12.234
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

string


POST
/pruebaWebService/Service1.asmx/HelloWorld HTTP/1.1
Host: 10.1.12.234
Content-Type: application/x-www-form-urlencoded
Content-Length: length
pSXml=string&pSNombre=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

string

PLEASE HELP ME.

THANKS.



Started By jorgeahm on Jul 24, 2006 at 11:53:26 AM

14 Response(s) | Reply

Earlier Replies | Replies 1 to 7 of 14 | Later Replies
Goto Page: 2 1
MHenke on Jul 25, 2006 at 2:35:11 AM (# 1)

Try to specify the correct Namespace for the response when registering your String deserializer, apart from that I'd guess that the name of your result element isn't "return" as you specify it.

soapMappingRegistry.mapTypes(
  Constants.NS_URI_SOAP_ENC,
  new QName(http://tempuri.org/,
  "HelloWorldResult"),
  null,
  null,
  new StringDeserializer()
);


jorgeahm on Jul 25, 2006 at 5:28:42 AM (# 2)

thanks for your help mhenke, this works now.


MHenke on Jul 25, 2006 at 6:14:30 AM (# 3)


jorgeahm on Jul 25, 2006 at 7:01:42 AM (# 4)

i have another question. the web services .net take two params and return Hello World +param1.

but when i call the web services the return is only Hello World. i think the web services don't take my params.

do you know why can happend this?


MHenke on Jul 25, 2006 at 7:44:14 AM (# 5)

Nope. If you call the web service and it returns w/o error, the return value has to be assumed as correct.
The rest depends on the service implementation. What makes you think that the return value isn't correct?


jorgeahm on Jul 25, 2006 at 8:14:32 AM (# 6)

when i call the page services for internet explorer, i write two params por example:
pSXml: hola
pSNombre: mundo

and the return is

Hello World mundo

but when i call the service in the java code, only return
Hello World. And i set the params like this

params.addElement(new Parameter("pSXml", String.class, "hola", null));
params.addElement(new Parameter("pSNombre", String.class, "mundo", null));


for this, i think the web services do not take my params.

this is true o false

thanks MHenke


MHenke on Jul 25, 2006 at 8:34:51 AM (# 7)

Have you looked at the SOAP response when calling the service through your Java client?


Earlier Replies | Replies 1 to 7 of 14 | Later Replies
Goto Page: 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.