bhagyas / wsdl2objc

Automatically exported from code.google.com/p/wsdl2objc
MIT License
0 stars 0 forks source link

Missing namespace in soap evelope request body #59

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. send request to jaxws metro 1.2 implementation
2.
3.

What is the expected output?

Get the soap response & http status 200

What do you see instead?

Soap Fault http status 500

What version of the product are you using? On what operating system?

Server : java jdk 6, tomcat 6 + jaxws + metro 1.2
Client : wsdl2objc 0.6, Mac OS 10.5.8 xcode 3.1.4, iPhone simulator 3.1.2

Please provide any additional information below.

Jaxws-metro require namespace for the body request. I use Java client generated 
classes from 
the same wsdl and the call is: 

---[HTTP request]---
Accept: application/soap+xml, multipart/related, text/html, image/gif, 
image/jpeg, *; q=.2, */*; 
q=.2
Content-Type: application/soap+xml;charset="utf-8";action=""
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns2:getSiteList xmlns:ns2="http://server.ws.dcartes.upd.fr/"/>
</S:Body>
</S:Envelope>--------------------
---[HTTP response 200]---
Transfer-encoding: chunked
null: HTTP/1.1 200 OK
Content-type: application/soap+xml;charset=utf-8
Server: Apache-Coyote/1.1
Date: Wed, 18 Nov 2009 10:21:57 GMT
<?xml version='1.0' encoding='UTF-8'?><S:Envelope 
xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body><ns2:getSiteListResponse xmlns:ns2="http://server.ws.dcartes.upd.fr/">
<xmlresult id="1">
<location longitude="5.4" latitude="10.2"/>
</xmlresult>
</ns2:getSiteListResponse>
</S:Body>
</S:Envelope>--------------------

And from iphone : 

OutputHeaders:
{
    "Content-Length" = 425;
    "Content-Type" = "application/soap+xml; charset=utf-8";
    Host = localhost;
    Soapaction = "";
    "User-Agent" = wsdl2objc;
}
2009-11-18 11:15:16.530 TestWs[375:20b] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:DcartesWSServiceSvc="http://server.ws.dcartes.upd.fr/" xsl:version="1.0">
  <soap:Body>
    <getSiteList xsi:type="DcartesWSServiceSvc:getSiteList"/>
  </soap:Body>
</soap:Envelope>
2009-11-18 11:15:16.781 TestWs[375:20b] ResponseStatus: 500
2009-11-18 11:15:16.781 TestWs[375:20b] ResponseHeaders:
{
    Connection = close;
    "Content-Type" = "application/soap+xml;charset=utf-8";
    Date = "Wed, 18 Nov 2009 10:15:16 GMT";
    Server = "Apache-Coyote/1.1";
    "Transfer-Encoding" = Identity;
}
2009-11-18 11:15:16.788 TestWs[375:20b] ResponseBody:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope 
xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<S:Fault xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/">
<S:Code>
<S:Value>S:Sender</S:Value>
</S:Code>
<S:Reason>
<S:Text xml:lang="fr">Cannot find dispatch method for {}getSiteList</S:Text>
</S:Reason>
</S:Fault>
</S:Body>
</S:Envelope>

The problem is here : <getSiteList xsi:type="DcartesWSServiceSvc:getSiteList"/>

should be something like : <ns1:getSiteList 
xmlns:ns1="https://targetnamespace"/>

It's a know issue from jaxws metro implementation to require namespace in the 
soap request. Is 
it possible to add this namespace in the - (NSString 
*)serializedFormUsingHeaderElements:(NSDictionary *)headerElements 
bodyElements:(NSDictionary *)bodyElements, in the bodyElements process ?

@+
Edo... 

Original issue reported on code.google.com by eddy.pel...@univ-paris5.fr on 18 Nov 2009 at 10:32

GoogleCodeExporter commented 9 years ago
I solve my problem by changing some lines

in - (NSString *)serializedFormUsingHeaderElements:(NSDictionary 
*)headerElements 
bodyElements:(NSDictionary *)bodyElements

1) I created a pointer to my namespace :

xmlNsPtr dcartesNs = xmlNewNs(root, (const 
xmlChar*)"http://server.ws.dcartes.upd.fr/", (const 
xmlChar*)"DcartesWSServiceSvc");

2) in the for(NSString *key in [bodyElements allKeys]) loop

I change the initial call to :

xmlAddChild(bodyNode, [body xmlNodeForDoc:doc elementName:key]);

by :

xmlNodePtr targetNode = xmlNewDocNode(doc, dcartesNs, (const 
xmlChar*)"getSiteList", NULL);

xmlAddChild( bodyNode, targetNode );

console output:

<soap:Body>
    <DcartesWSServiceSvc:getSiteList/>
  </soap:Body>

It is hard coded and ugly but it works. But the wright place to change it's in 
- 
(xmlNodePtr)xmlNodeForDoc:(xmlDocPtr)doc elementName:(NSString *)elName I 
think. I will try toworrow.

now  I have an exception for response, I receive correctly the message. but 
it's another story. :)

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
'*** -[NSCFString 
longValue]: unrecognized selector sent to instance 0x3d2b340'

Original comment by eddy.pel...@univ-paris5.fr on 18 Nov 2009 at 6:18

GoogleCodeExporter commented 9 years ago
@eddy.pelaic, do you have the fix for "unrecognized selector sent to instance" 
? It's bugging me for some time 
now.. still tracking it down..

Original comment by alexej.k...@gmail.com on 5 Dec 2009 at 9:43

GoogleCodeExporter commented 9 years ago
Actually, i solved it by re-saving the delegate for my operation into another 
object. Very weird by delegate 
seemed to be changing to NSMachPort instead of my delegate class.

so for my Operation's -(id)initWithBinding:delegate:parameters i declared a 
property "deleg" and set it to 
reference to responseDelegate.

Then in -(void)connectionDidFinishLoading i swapped all references to 
"delegate" with "deleg" and it all 
worked like a charm!

I am quite new to Objective-C and iPhone/OSX Dev and its a bit hard for me to 
track down the reason for this 
issue... but IT seems to be working right now.

Original comment by alexej.k...@gmail.com on 5 Dec 2009 at 10:49

GoogleCodeExporter commented 9 years ago
Ok, sorry for all the posts, but... i think i might've found the problem.

For my HelloWorld service the following property is generated:
@property (nonatomic, assign) id<HelloWorldSoapResponseDelegate> delegate;

And this seems to be causing loads of weird behaviors, like changing references 
and so on (like i wrote 
above).
But if i change it from "assign" to "retain" it works like a charm.

I only now noticed that my "deleg" property i mentioned in the previous post 
was simply "retain" property and 
not "assign".

Well, lot's of things can be missed at first when doing stuff late at 
night/early in the morning :D

P.S.: Someone more experienced in objective-c should probably verify that this 
aint causing any memory 
leaks or so.. i think a [delegate release] might be in place in dealloc method.

Original comment by alexej.k...@gmail.com on 5 Dec 2009 at 11:40

GoogleCodeExporter commented 9 years ago
Hi Eddy

I hit this problem too, and your post gave me some advice on what on to do. 

I fixed it by modifying the xmlNodeForDoc method for the top most (outermost) 
element
only so that it includes the namespace. 
before:
    xmlNodePtr node = xmlNewDocNode(doc, NULL, (const xmlChar*)[elName UTF8String], NULL);
:after
    xmlNodePtr node = xmlNewDocNode(doc, myNS, (const xmlChar*)[elName UTF8String], NULL);

where I've defined 
    xmlNsPtr myNS = xmlSearchNs(doc, root, (const xmlChar*)"myNameSpace");

This seems to work OK. 
It must be a jax-ws thing. It's not my web-service i'm testing against, so 
can't get
them to make any adjustments either. 

Cheers!
and please let me know if there is better fix

Original comment by hypot...@gmail.com on 9 Dec 2009 at 3:35

GoogleCodeExporter commented 9 years ago
I guys!
@alexej.kubarev 
my problem with "unrecognized selector sent to instance" is that My Java Object 
use java.lang.Long type and 
wsdl2objc use a call to [NSString longValue] who does not exist in this class. 
I change for java.lang.Integer 
and it works. Whitch Objective-c type could be used for long value..?

@hypotize
I will try soon, but I am working on the Java side off my app to finish my 
WebService interface, I must do it 
before testing client side. 

@+
Edo...

Original comment by eddy.pel...@univ-paris5.fr on 20 Jan 2010 at 9:47

GoogleCodeExporter commented 9 years ago
[ERROR] Exception occurred while trying to invoke service method Authentication
org.apache.axis2.AxisFault: namespace mismatch require 
http://ws.apache.org/axis2 found  http://192.168.152.190:8082/SoapService
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:177)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
[ERROR] namespace mismatch require http://ws.apache.org/axis2 found  
http://192.168.152.190:8082/SoapService
org.apache.axis2.AxisFault: namespace mismatch require 
http://ws.apache.org/axis2 found  http://192.168.152.190:8082/SoapService
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:177)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

Please Help ME!!!!!!

Original comment by rausha...@gmail.com on 31 Jul 2013 at 3:00