xml - WSDL error: SOAP-ERROR: Parsing WSDL: Couldn't bind to service

16
2014-04
  • thom
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions
        xmlns="http://schemas.xmlsoap.org/wsdl/" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://localhost:8888/testes/wsdl/calculadora.wsdl">
        <message name="requisicaoSoma">
            <part name="x" type="xsd:int" />
            <part name="y" type="xsd:int" />
        </message>
        <message name="respostaSoma">
            <part name="z" type="xsd:int" />
        </message>
        <portType name="calculadoraPortType">
            <operation name="soma">
                <input message="requisicaoSoma" />
                <output message="respostaSoma" />
            </operation>
        </portType>
        <binding name="calculadoraBinding" type="tns:calculadoraPortType">
            <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation>
                <soap:operation soapAction="http://localhost:8888/testes/calculadora.php" />
                <input><soap:body use="literal" /></input>
                <output><soap:body use="literal" /></output>
            </operation>
        </binding>
    </definitions>
    

    Am I missing something? Thank you.

  • Answers
  • Purnima

    You have not defined the service element of the WSDL. For more information refer to the below links.

    WSDL Essentials

    Sample WSDL


  • Related Question

    flex - How can I pass the string "Null" through WSDL (SOAP) from ActionScript 3 to a ColdFusion web service without receiving a "missing parameter error"?
  • bill

    We have an employee whose last name is Null. He kills our employee lookup application when his last name is used as the search term (which happens to be quite often now). The error received (thanks Fiddler!) is

      <soapenv:Fault>
       <faultcode>soapenv:Server.userException</faultcode>
       <faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.MissingArgumentException : The SEARCHSTRING parameter to the getFacultyNames function is required but was not passed in.]</faultstring>
    

    Cute, huh?

    The parameter's type is string.

    I am using:

    • WSDL (SOAP).
    • Flex 3.5
    • ActionScript 3
    • ColdFusion 8

    Note that the error DOES NOT occur when calling the webservice as an object from a ColdFusion page.


  • Related Answers
  • Ben Burns

    Tracking it down

    At first I thought this was a coercion bug where null was getting coerced to "null" and a test of "null" == null was passing. It's not. I was close, but so very, very wrong. Sorry about that!

    I've since done lots of fiddling on wonderfl.net and tracing through the code in mx.rpc.xml.*. At line 1795 of XMLEncoder (in the 3.5 source), in setValue, all of the XMLEncoding boils down to

    currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));
    

    which is essentially the same as:

    currentChild.appendChild("null");
    

    This code, according to my original fiddle, returns an empty XML element. But why?

    Cause

    According to commenter Justin Mclean on bug report FLEX-33664, the following is the culprit (see last two tests in my fiddle which verify this):

    var nullXML:XML = <root>null</root>;
    if(nullXML == null){
        //always branches here, as (nullXML == null) == true
    }
    

    When currentChild.appendChild is passed the string "null", it first converts it to a root XML element with text null, and then tests that element against the null literal. This is a weak equality test, so either the XML containing null is coerced to the null type, or the null type is coerced to a root xml element containing the string "null", and the test passes where it arguably should fail. One fix might be to always use strict equality tests when checking XML (or anything, really) for "nullness."

    Solution

    The only reasonable workaround I can think of, short of fixing this bug in every damn version of ActionScript, is to test fields for "null" and escape them as CDATA values.

    CDATA values are the most appropriate way to mutate an entire text value that would otherwise cause encoding/decoding problems. Hex encoding, for instance, is meant for individual characters. CDATA values are preferred when you're escaping the entire text of an element. The biggest reason for this is that it maintains human readability.

  • BoltClock

    The problem could be in Flex's SOAP encoder. Try extending the SOAP encoder in your Flex application and debug the program to see how the null value is handled. My guess is, it's passed as NaN (Not a Number). This will mess up SOAP message unmarshalling process sometime (most notably in JBoss 5 server...). I remember extending the SOAP encoder and performing an explicit check on how NaN is handled.

    (On a side note, are you expected to do something useful if employee id is Null, is this not an validation issue? I could be wrong, since I hardly know the requirement...)

  • Peter Mortensen

    On the xkcd note, the Bobby Tables website has good advice for avoiding the improper interpretation of user data (in this case, the string "Null") in SQL queries in various languages, including ColdFusion.

    It is not clear from the question that this is the source of the problem, and given the solution noted in a comment to the first answer (embedding the parameters in a structure) it seems likely that it was something else.

  • JeffryHouser

    @doc_180 had the right concept, except he is focused on numbers, whereas the original poster had issues with strings.

    The solution is to change the mx.rpc.xml.XMLEncoder file. This is line 121

        if (content != null)
            result += content;
    

    [I looked at Flex 4.5.1 SDK; line numbers may differ in other versions]

    Basically, the validation fails because 'content is null' and therefore your argument is not added to the outgoing SOAP Packet; thus causing the missing parameter error.

    You have to extend this class to remove the validation. Then there is a big snowball up the chain, modifying SOAPEncoder to use your modified XMLEncoder, and then modifying Operation to use your modified SOAPEncoder, and then moidfying WebService to use your alternate Operation class.

    I spent a few hours on it, but need to move on. It'll probably take a day or two.

    You may be able to just fix the XMLEncoder line and do some monkey patching to use your own class.

    I'll also add that if you switch to using RemoteObject/AMF with ColdFusion, the null is passed without problems.


    11/16/2013 update:

    I have one more recent addition to my last comment about RemoteObject/AMF. If you are using CF10; then properties with a null value on an object are removed from the server side object. So, you have to check for the properties existence before accessing it or you will get a runtime error. Check like this:

    <cfif (structKeyExists(arguments.myObject,'propertyName')>
     <!--- no property code --->
    <cfelse>
     <!--- handle property  normally --->
    </cfif>
    

    This is a change in behavior from CF9; where the null properties would turn into empty strings.


    Edit 12/6/2013

    Since there was a question about how nulls are treated here is a quick sample application to demonstrate how a string "null" will relate to the reserved word null.

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="application1_initializeHandler(event)">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
    
                protected function application1_initializeHandler(event:FlexEvent):void
                {
                    var s :String = "null";
                    if(s != null){
                        trace('null string is not equal to null reserved word using the != condition');
                    } else {
                        trace('null string is equal to null reserved word using the != condition');
                    }
    
                    if(s == null){
                        trace('null string is equal to null reserved word using the == condition');
                    } else {
                        trace('null string is not equal to null reserved word using the == condition');
                    }
    
                    if(s === null){
                        trace('null string is equal to null reserved word using the === condition');
                    } else {
                        trace('null string is not equal to null reserved word using the === condition');
                    }
    
                }
    
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
    </s:Application>
    

    The trace output is:

    null string is not equal to null reserved word using the != condition

    null string is not equal to null reserved word using the == condition

    null string is not equal to null reserved word using the === condition

  • doogle

    Translate all characters into their hex-entity equivalents. In this case, Null would be converted into &#4E;&#75;&#6C;&#6C;

  • Peter Mortensen

    As a hack, you could consider having a special handling on the client side, converting 'Null' string to something that will never occur, for example, XXNULLXX and converting back on the server.

    It is not pretty, but it may solve the issue for such a boundary case.

  • Andrew Aylett

    Stringifying a null value in actionscript will give the string "NULL". My suspicion is that someone has decided that it is, therefore, a good idea to decode the string "NULL" as null, causing the breakage you see here -- probably because they were passing in null objects and getting strings in the database, when they didn't want that (so be sure to check for that kind of bug, too).

  • Peter Mortensen

    Well, I guess that Flex' implementation of the SOAP Encoder seems to serialize null values incorrectly. Serializing them as a String Null doesn't seem to be a good solution. The formally correct version seems to be to pass a null value as:

    <childtag2 xsi:nil="true" />
    

    So the value of "Null" would be nothing else than a valid string, which is exactly what you are looking for.

    I guess getting this fixed in Apache Flex shouldn't be that hard to get done. I would recommend opening a Jira issue or to contact the guys of the apache-flex mailinglist. However this would only fix the client side. I can't say if ColdFusion will be able to work with null values encoded this way.

    See also Radu Cotescu's blog post How to send null values in soapUI requests.

  • SPitBalls.com

    It's a kludge, but assuming there's a minimum length for SEARCHSTRING, for example 2 characters, substring the SEARCHSTRING parameter at the second character and pass it as two parameters instead: SEARCHSTRING1 ("Nu") and SEARCHSTRING2 ("ll"). Concatenate them back together when executing the query to the database.