Sending raw XML with php nusoap client

In my last blog post I described how to use wsdl2php to parse a wsdl file and generate php classes. This should make your life a lot simpler when dealing with SOAP Web Services.

But there are times that all the frameworks and toolkits in the world wont be able to produce the desired plain XML structure of the SOAP call. Especially when you are working with Chinese low-end equipment.

I usually work in php nusoap and I had trouble finding the right way to do this. I was so desperate, that I have been posting raw XML with CURL to mimic the SOAP Request. Luckily I found a way to do i with our favourite php soap toolkit.

Thow following is an example that calls a function insertUser with raw XML:


require_once('nusoap/lib/nusoap.php');

$endpoint = "http://yoursoapserver.com/SomeSoapService";

$client = new nusoap_client($endpoint, false);

$msg = $client->serializeEnvelope("
<ns1:insertuser xmlns:1="http://yoursoapserver.com/">
  <arg0 xsi:type="xsd:string">name</arg0>
  <arg1>
    <username xsi:type="xsd:string">username</username>
    <password xsi:type="xsd:string">0ac495f743a36cef9b0eaafa92ae08e21</password>
  </arg1>
  <arg2 xsi:type="xsd:string">email</arg2>
  <arg3 xsi:type="xsd:string">domain</arg3>
</ns1:insertuser>
");

$result=$client->send($msg, $endpoint);

print_r($result);

30 comments:

  1. Could you please post a server example to the above code.

    ReplyDelete
    Replies
    1. What do you mean by a server example? I have usually used this when I have worked with predefined SOAP servers

      Delete
  2. hi i m used the same code but i got error "Response not of type text/xml: text/html; charset=UTF-8" any idea why this occurred . i am using 3 party web services

    ReplyDelete
  3. hi i saw your webservice article its nice. i have question regarding soap webservice i want to use dot.net soap webservice in my php soap service . do u have any idea how can i acheive it . thanks

    ReplyDelete
  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
    Selenium training in Chennai

    Selenium training in Bangalore

    ReplyDelete

  5. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb.
    This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity. I appreciated what you ok extremely here 


    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  6. Thanks For sharing Your Information The Information shared Is Very Valuable Please Keep Updating Us Python Online Course Hadoop Online Course Data Science Online Course Aws Online Course

    ReplyDelete
  7. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know. Nice! thank you so much! Thank you for sharing.
    redmi service center in velachery
    redmi note service center in chennai
    redmi mobile service centre in chennai

    ReplyDelete
  8. I have read your blog its very attractive and impressive. I like it your blog. digital marketing training in bangalore

    ReplyDelete
  9. Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.citrix training in bangalore

    ReplyDelete
  10. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful .Informatica Training in Bangalore

    ReplyDelete
  11. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.Informatica Training in Bangalore

    ReplyDelete
  12. Such a great information for blogger i am a professional blogger thanks…

    Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also, it provides placement assistance service in Bangalore for IT.

    ReplyDelete
  13. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing...

    learn data science online

    ReplyDelete
  14. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing...


    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

    AWS online training

    ReplyDelete
  15. Hola. Dentro del mensaje XML puedo insertar una variable PHP ? Gracias

    ReplyDelete
  16. ood Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers.
    salesforce training in chennai

    software testing training in chennai

    robotic process automation rpa training in chennai

    blockchain training in chennai

    devops training in chennai

    ReplyDelete
  17. Expected to create you a tiny word to thank you once more in regards to the pleasant ideas you've contributed here…

    Data Science Training in Hyderabad

    ReplyDelete
  18. Thankful for Sharing This Article. It is incredibly such a ton of huge substance. I trust these Commenting records will serve to my site…

    Data Science Training in Hyderabad

    ReplyDelete

  19. Quick up your career with Azure Training in Chennai from Infycle Technologies, the best software training institute in Chennai. A massive place to learn topmost technical courses like Medical Coding, Mobile App Development, Data Science, Big Data, BlockChain, Full Stack Development, Digital Marketing with Graphic Design, Python, and Oracle with emphasized trainers of the industry. Speak to us on 7504633633, 7502633633 to know the updated offers for your learning.

    ReplyDelete
  20. FuboTV is an super choice for sports activities fans considering that there is no scarcity of stay streaming.FuboTV has all the regional sports activities networks to seize each sport of your preferred team. you can add-on different channels, which include top class channels. fubo.tv/connect
    fubo connect

    ReplyDelete
  21. Nice Article. It was Really Helpful to me Thanks for Sharing
    CEC Best Colleges in Hyderabad

    ReplyDelete
  22. I am grateful for your willingness to share your thoughts. Your efforts are truly appreciated and I look forward to reading more from you. Thank you again.

    B.Com Computers Colleges in Hyderabad

    ReplyDelete
  23. Your blog is excellent and captivating. Please continue to share more informative posts like this. It was very helpful. Thank you for sharing. Check out my website.

    Best CA Academy in Hyderabad

    ReplyDelete
  24. Unlock the power of cybersecurity with our top-notch training in Hyderabad. Join us to become a certified expert and protect the digital world from cyber threats. Stay ahead in this rapidly evolving field and secure a brighter future for yourself.

    Cyber Security Training in Hyderabad

    ReplyDelete