doedje / jquery.soap

This script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
352 stars 148 forks source link

SOAP Error #90

Closed mustafizurrohman closed 8 years ago

mustafizurrohman commented 8 years ago

Hello, I am facing a problem while calling my asmx SOAP service. My javascript/ajax code is as follows:

$.soap({
            url: "https://exampleurl.com/service1.asmx",       // url is correct 
            method: "examplemethod",                          // optional
            appendMethodToURL: false,                        // 404 error when set to 'true'
            soap12: true,                                   // SOAP 1.2 Request
            // SOAPAction: "http://tempuri.org/examplemethod", // Optional for 1.2
            // context: document.body,
            enableLogging: true,   // logging enabled for debugging

            // For JSON
            data: {
                parameter1 : 'data1',
                parameter3 : 'data2',
                parameter3 : 'data3',
                parameter4 : 'data4'
            }, 

            beforeSend: function (SOAPEnvelope) {
                alert("Sending : \n\n\n" + SOAPEnvelope);
                // console.log("Sending : \n\n\n" + SOAPEnvelope);
            },

            sucess: function (soapResponse) {
                alert("SUCESSFUL SOAP Response : \n\n\n" + soapResponse);
                // console.log("SUCESSFUL SOAP Response : \n\n\n" + soapResponse);
            },

            error: function (SOAPResponse) {
                alert("FAILED SOAP Response : \n\n\n" + SOAPResponse)
                // console.log("FAILED SOAP Response : \n\n\n" + SOAPResponse);
            },

            // callback functions based on statusCode
            statusCode: {                                   
                404: function () {
                    alert('404 Not Found');
                    // console.log('404 Not Found');
                },
                200: function () {
                    alert('200 OK');
                    // console.log('200 OK');
                }
            }
    });

For this code I always get the following fail message:

<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
            <soap:Fault>
                <soap:Code>
                    <soap:Value>soap:Receiver</soap:Value>
                </soap:Code>
                <soap:Reason>
                    <soap:Text xml:lang="en">
                        The request could not be processed by the server. --- & gt; The root element is missing.
                    </soap:Text>
                </soap:Reason>
                <soap:Detail/>
            </soap:Fault>
        </soap:Body>
    </soap:Envelope>

It would be nice if anyone could kindly shed some light on the error. I have been trying to fix this for the last few hours without success. Thank you. Cheers.

Mustafizur

doedje commented 8 years ago

My guess is you should set the method correctly, it should match a valid service operation name.

https://github.com/doedje/jquery.soap/blob/master/doc/options.md#method

mustafizurrohman commented 8 years ago

This was an example. I changed it to a real method name but unfortunately the problem is still there.

doedje commented 8 years ago

Than my advice would be to use the WSDL of your service in the SoapUI application and see what the calls look like in there and try to recreate that with the jquery.soap demo page... Example code like the one you provided is not helping me in seeing what might be wrong. The method suggestion was merely based on the // optional remark behind it.... =]

doedje commented 8 years ago

The // optional and the error message about a missing rootnode.... What does your outgoing XML look like?

mustafizurrohman commented 8 years ago

Thank you for your kind reply. Here is my outgoing XML.

outgoingxml

doedje commented 8 years ago

Hmm, might be needing a namespace for the resetAccount node.... Please try with WSDL and SoapUI... That shows you what the calls should look like..

mustafizurrohman commented 8 years ago

You are right. Absolutely right. It should be as follows :

correct

Kindly let me know who can I set it. Thank you very much.

doedje commented 8 years ago

add the following:

  namespaceURL: "http://tempuri.org",

By the way, to add xml or code to your comments on github you can use the following markdown: fenced code blocks Saves you the trouble of making screenshots ;)

mustafizurrohman commented 8 years ago

Thank you very much. It still does not work, unfortunately.

doedje commented 8 years ago

try soapui, it really is great for debugging soap...

mustafizurrohman commented 8 years ago

Thank you. I will. Have a nice day!

doedje commented 8 years ago

you too, good luck and let me know when you do or don't succeed... One last suggestion I would like to give you is looking at the serverside.... Missing the root element might suggest the server is not receiving anything.... Or is looking for the soap message in the wrong place...

doedje commented 8 years ago

(can I close this issue? are you doing fine?)

mustafizurrohman commented 8 years ago

Sorry for my late response .. Unfortunately I could not get it to work and decided to use something else. Kindly close the issue. Thank you. Have a nice weekend!