SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Soap

  1. #1
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Soap

    Hi,

    I'm starting to work with SOAP and I need some help.
    I have the following XML scheme:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    *<soap:Body>
    **<getCountryList xmlns="https://www.name.net/XMLWS/Services/">
    ***<AffiliateID>int</AffiliateID>
    ***<Password>string</Password>
    ***<LanguageCode>en</LanguageCode>
    **</getCountryList>
    *</soap:Body>
    </soap:Envelope>
    I am able to get a response back using this code:
    PHP Code:
    $ch curl_init();
    curl_setopt($chCURLOPT_URL"https://www.name.com/XMLWS/Services/Content/Content.asmx");
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    curl_setopt($chCURLOPT_HTTPHEADER, Array("Content-Type: text/xml; charset=utf-8""Content-Length: "strlen($soap), "SOAPAction: \"https://www.name.net/XMLWS/Services/getCountryList\""));
    curl_setopt($chCURLOPT_POST1);
    curl_setopt($chCURLOPT_POSTFIELDS$soap);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    $result curl_exec($ch); 
    ...but it's returning a country list only for english language. How can I send a soap message but to return country list in multiple languages: en, de, it, fr... ? I suppose is from w3 xml scheme, or something. Anyway, I tried to look over those schemes from envelope but I couldn't understood much things. Just an idea, a nice tutorial as for a SOAP beginner.

    Thanks!

  2. #2
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've not used this approach and have no expert advice for you, but you will notice the following in the XML scheme:

    Code:
    <LanguageCode>en</LanguageCode>

  3. #3
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but if I use it this way
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    *<soap:Body>
    **<getCountryList xmlns="https://www.name.net/XMLWS/Services/">
    ***<AffiliateID>int</AffiliateID>
    ***<Password>string</Password>
    ***<LanguageCode>en</LanguageCode>
    ***<LanguageCode>es</LanguageCode>
    ***<LanguageCode>de</LanguageCode>
    **</getCountryList>
    *</soap:Body>
    </soap:Envelope>
    ...it will return the list in the las language specified (de in this case).
    Of course I can make more requests, one for each language, but exactly this is what I want to avoid.

    From my first post I searched on the net and found some info about namespaces. I think this I have to use but I don't know how yet.
    Useful for beginners

  4. #4
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It may be that their service is only set up to return one language at a time. Perhaps you can use PHP's environment information to guess the user's country or have a select menu with a list of countries they can choose from so you know which one to pass the soap service.

  5. #5
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it is no alternative. I have an application that is in 5 different languages. This application it's interacting with other applications from which I get country names, city names and other informations in every language my application supports. Every other application interacts with mine in a different way. Some I transmit only GET request, for others I have to POST some fields and for this one I have to use SOAP. So an alternative is not an option. In fact there is no alternative.

  6. #6
    PEACE WILL WIN abalfazl's Avatar
    Join Date
    Feb 2005
    Location
    Beyond the seas there is a town
    Posts
    711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I shall build a boat,I shall cast it in the water,
    I shall sail away from this strange earth,
    Where no one awaken the heroes in the wood of love

  7. #7
    PEACE WILL WIN abalfazl's Avatar
    Join Date
    Feb 2005
    Location
    Beyond the seas there is a town
    Posts
    711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I shall build a boat,I shall cast it in the water,
    I shall sail away from this strange earth,
    Where no one awaken the heroes in the wood of love

  8. #8
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use SOAP class from PHP.
    When var_dump($client->__getFunctions()); I get between many other this function which I need: string(65) "getCountryListResponse getCountryList(getCountryList $parameters)". I call it this way: $client->__soapCall("getCountryList", array("AffiliateID" => 0000, "Password" => "ppaassww", "LanguageCode" => "en")) and I get Uncaught SoapFault exception: [soap:Client] System.Web.Services.Protocols.SoapException: Invalid AffiliateID at Content.getCountryList(Int32 AffiliateID, String Password, String LanguageCode). What I am doing wrong? And also, I am able to send a request for more languages at once?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •