locked
There is an error in XML document (1, 472). RRS feed

  • Question

  • Hi,

    I have created web service in php having one method which returns array.

    I am consuming this web service in asp.net. 

    The above exception is thrown while try to call method from c#. But if I changed return type of method in webservice to the string then its working fine. I need to return string array from php webservice. 

    My PHP service page contains the following code:

    -----------------------------------------------

    <?php
     /**
     * wsGetJourney method
     * @param string $who name of the person we'll say hello to
     * @return string $helloText the hello  string
     */
    function wsGetJourney($id) {
        
        if($id==1)
        {
            return array('101'=>'Maharashtra','102'=>'Karnataka');
        }
        else
        {
            return array('101'=>'Tamilnadu','102'=>'Goa');
        }
    }

    require_once("nusoap.php");

    $namespace = "http://tempuri.org";

    // create a new soap server
    $server = new soap_server();
    // configure our WSDL
    $server->configureWSDL("wsSpiceNight");
    // set our namespace
    $server->wsdl->schemaTargetNamespace = $namespace;
    // register our WebMethod
    $server->register(
                    // method name:
                    'wsGetJourney',  
                    // parameter list:
                    array('name'=>'xsd:string'), 
                    // return value(s):
                    array('return'=>'xsd:ArrayOfString'),/*ArrayOfString*/
                    // namespace:
                    $namespace,
                    // soapaction: (use default)
                    false,
                    // style: rpc or document
                    'rpc',
                    // use: encoded or literal
                    'encoded',
                    // description: documentation for the method
                    'A simple Hello World web method');

                    
    // Get our posted data if the service is being consumed
    // otherwise leave this data blank.                
    $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) 
                    ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

    // pass our posted data (or nothing) to the soap service                    
    $server->service($POST_DATA);                
    exit();

    ?>

    -------------------------------------------------------------------

    And I am consuming webservice in asp.net by adding service reference(Add web reference).

    Please let me know if I am doing something wrong. 

    Regards,

    Swapnil


    Wednesday, September 12, 2012 11:36 PM

All replies

  • We're not so expert in that subject here. I'd ask again at http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads

    http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, please vote and/or mark the question answered. Available for contract programming.

    Friday, September 14, 2012 10:33 AM
  • A webpage can't return an object unless it is in a tagged object.  An array string must have the strings serperated by a delimiter.  Then use a split method to make them an array object.

    first I would look at the string that is being returned when the code works.  See if there is a delimiter between the strings.  Then let the code use string and the use the spilt method to create an arrray of string in your service.


    jdweng

    Friday, September 14, 2012 10:34 AM