prajapatipranay / wsdl2objc

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

missing method name inside soap request #69

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

What is the expected output?

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:="http://www.w3.org/2001/XMLSchema" xmlns:FoodFactsSvc="http://services" 
xmlns:tns1="http://rpc.xml.coldfusion" 
xmlns:ns1="http://xml.apache.org/xml-soap" 
xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsl:version="1.0">
  <soap:Body>
    <getCategoryIcon>
      <intCategoryID>13<intCategoryID>
    </getCategoryIcon>
  </soap:Body>
</soap:Envelope>
What do you see instead?

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:="http://www.w3.org/2001/XMLSchema" xmlns:FoodFactsSvc="http://services" 
xmlns:tns1="http://rpc.xml.coldfusion" 
xmlns:ns1="http://xml.apache.org/xml-soap" 
xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsl:version="1.0">
  <soap:Body>
      <intCategoryID>13<intCategoryID>
     </soap:Body>
</soap:Envelope>
What version of the product are you using? On what operating system?
wsdl2objcversion 0.6

Please provide any additional information below.
modified the code for serializedFormUsingHeaderElements

        xmlNodePtr methodNode = xmlNewDocNode(doc, NULL, (const 
xmlChar*)"getCategoryIcon", NULL);
    xmlNsPtr methodNs = xmlNewNs(methodNode, (const xmlChar*)"http://services",
                                     (const xmlChar*)"FoodFactsSvc");
        xmlSetNs(methodNode, methodNs);
        xmlAddChild(bodyNode, methodNode); 

but it still gives error:

ResponseStatus: 500
ResponseHeaders:
{
    Connection = close;
    "Content-Type" = "text/xml; charset=utf-8";
    Date = "Fri, 05 Feb 2010 09:51:12 GMT";
    Server = "Microsoft-IIS/6.0";
    "Set-Cookie" = "CFID=820236;expires=Sun, 29-Jan-2040 09:51:12 GMT;path=/, 
CFTOKEN=c81f5b58022f1b9b-9D8A5022-FD9C-18F0-DE9F165FECBDD266;expires=Sun, 29-
Jan-2040 09:51:12 GMT;path=/";
    "X-Powered-By" = "ASP.NET";
}
2010-02-05 15:21:06.723 FoodFactsNav[5315:20b] ResponseBody:
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>org.xml.sax.SAXParseException: Element or attribute do not match QName 
production: QName::=(NCName':')?NCName. </faultstring>
   <detail>
    <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">kelvinator</ns1:hostname>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>
Program received signal:  “EXC_BAD_ACCESS”.

this is how i'm calling the service:
----------------------------

FoodFacts_cfcSoapBinding *binding = [FoodFactsSvc FoodFacts_cfcSoapBinding];
    binding.logXMLInOut = YES;
    binding.authUsername = @"IPhone";
    binding.authPassword = @"FFIPhone856";

    NSNumber* id = [NSNumber numberWithInt:13];

    FoodFacts_cfcSoapBindingResponse *response = [binding 
getCategoryIconUsingIntCategoryID:id]; 

Original issue reported on code.google.com by developm...@raisesolutions.com on 5 Feb 2010 at 11:17

Attachments:

GoogleCodeExporter commented 8 years ago
I am seeing this exact same behavior in my application. The only thing I can 
add to what was posted above is 
that the service I am connecting to was written/generated via Apache Axis. Not 
sure if that makes a difference or 
not.

Original comment by corey.th...@gmail.com on 11 Feb 2010 at 12:14

GoogleCodeExporter commented 8 years ago
I was able to workaround this issue. I changed the serialization method to what 
is shown below and then 
updated all of the invocations to pass in the method name and it seems to work.

<code>
- (NSString *)serializedFormUsingHeaderElements:(NSString*) methodName 
:(NSDictionary *)headerElements 
:(NSDictionary *)bodyElements
{
    xmlDocPtr doc;

    doc = xmlNewDoc((const xmlChar*)XML_DEFAULT_VERSION);
    if (doc == NULL) {
        NSLog(@"Error creating the xml document tree");
        return @"";
    }

    xmlNodePtr root = xmlNewDocNode(doc, NULL, (const xmlChar*)"Envelope", NULL);
    xmlDocSetRootElement(doc, root);

    xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const 
xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/", (const 
xmlChar*)"soapenv");
    xmlSetNs(root, soapEnvelopeNs);

    //xmlNsPtr xslNs = xmlNewNs(root, (const xmlChar*)"http://www.w3.org/1999/XSL/Transform", (const 
xmlChar*)"xsl");
    /*xmlNsPtr xsiNs = */xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema-instance", 
(const xmlChar*)"xsi");

    //xmlNewNsProp(root, xslNs, (const xmlChar*)"version", (const xmlChar*)"1.0");

    xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema", (const xmlChar*)"xsd");
    xmlNsPtr serviceNs = xmlNewNs(root, (const xmlChar*)"http://webservice.memmgmt.stercomm.com/", 
(const xmlChar*)"web");
    xmlNewNs(root, (const xmlChar*)"http://model.memmgmt.stercomm.com", (const xmlChar*)"tns1");
    //xmlNewNs(root, (const xmlChar*)"http://xml.apache.org/xml-soap", (const xmlChar*)"apachesoap");
    xmlNewNs(root, (const xmlChar*)"http://schemas.xmlsoap.org/soap/encoding/", (const xmlChar*)"ns1");

    if((headerElements != nil) && ([headerElements count] > 0)) {
        xmlNodePtr headerNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Header", NULL);
        xmlAddChild(root, headerNode);

        for(NSString *key in [headerElements allKeys]) {
            id header = [headerElements objectForKey:key];
            xmlAddChild(headerNode, [header xmlNodeForDoc:doc elementName:key]);
        }
    }

    if((bodyElements != nil) && ([bodyElements count] > 0)) {
        xmlNodePtr bodyNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Body", NULL);
        xmlAddChild(root, bodyNode);

        xmlNodePtr methodNode = xmlNewDocNode(doc, serviceNs, (const xmlChar*) [methodName 
UTF8String], NULL);
        xmlAddChild(bodyNode, methodNode);

        for(NSString *key in [bodyElements allKeys]) {
            id body = [bodyElements objectForKey:key];
            xmlAddChild(methodNode, [body xmlNodeForDoc:doc elementName:key]);
            //xmlSetNsProp(childNode, xsiNs, (const xmlChar*) "type", (const xmlChar*) "xsd:string");
        }
    }

    xmlChar *buf;
    int size;
    xmlDocDumpFormatMemory(doc, &buf, &size, 1);

    NSString *serializedForm = [NSString stringWithCString:(const char*)buf 
encoding:NSUTF8StringEncoding];
    xmlFree(buf);

    xmlFreeDoc(doc);    
    return serializedForm;
}
</code>

Original comment by corey.th...@gmail.com on 11 Feb 2010 at 1:45

GoogleCodeExporter commented 8 years ago
Same issue here with latest svn. The workaround from comment #2 works, but is 
obviously not ideal.

Original comment by krabien on 1 Mar 2011 at 1:39