Solved

Change Namespace SOAP

Posted on 2014-09-10
3
493 Views
Last Modified: 2016-02-26
Hello I am sending XML using SOAP and I need to change the namespace. Below is the code I am using and the results I am getting and what I need to change it to..Any help would be greatly appreciated.

Thanks


Current Script
<?php 

$client = new SoapClient('http://www.dfwebservice.net/DfcsRemittance.asmx?WSDL', array('soap_version' => SOAP_1_2,				'trace' => 1,
		'use' => SOAP_LITERALL,
        'style' => SOAP_DOCUMENT,
		'encoding'=>' UTF-8'));
		
		$typedVar = new SoapVar("mystring", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$params = '<RemittanceRequest><RequestType>BranchListRequest</RequestType><agent>BWS</agent><userid>wbsuser</userid><password>pass@wbs</password></RemittanceRequest>';	
$params = new SoapVar($params, XSD_ANYXML);
	
$result = $client->GetBranchListXML($params);
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";

print_r($result);

Open in new window


The request comes out as

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://dfwebservice.net/"><env:Body>
<RemittanceRequest>
<RequestType>BranchListRequest</RequestType>
<agent>BWS</agent>
<userid>wbsuser</userid>
<password>pass@wbs</password>
</RemittanceRequest>
</env:Body>
</env:Envelope>

But I need the request to come out as

<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>
                                <RemittanceRequest>
                                <RequestType>BranchListRequest</RequestType>"
                                <agent>BWS</agent>"
                                 <userid>wbsuser</userid>"
                                <password>pass@wbs</password>
                               </RemittanceRequest>
                                             </soap:Body>
                                                </soap:Envelope>


Thank you for your help!
0
Comment
Question by:bradley525
  • 2
3 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40314523
I don't mean to dash your hopes, but I want to share a risk you're facing.  PHP SOAP support is not very good.  Here is the bug list.  As you can see, there are many bugs that are several years old, suggesting that they are never going to get fixed.  (You may have to copy/paste this URL.  It looks like the EE link builder does not understand arrays.)
https://bugs.php.net/search.php?cmd=display&order_by=id&direction=DESC&limit=30&phpver=5.3&package_name[]=SOAP+related

One such bug involves namespaces.   Variables with the same name, but in different namespaces, collide.  WTF you might say, what's the point of namespaces?  Well, that is exactly what I said when I hit the bug.  It caused a failed project for me after an investment of more than a week of my life.  Hopefully you won't have that experience with your project.

If there is any way at all to get the client to expose a RESTful interface to the API, choose that instead.  If you have to continue to use SOAP, consider NuSOAP (Google it).  It may be better at getting around the vagaries of PHP SOAP support.
0
 

Author Comment

by:bradley525
ID: 40314540
Ok do you have experience with nusoap they do not have a restful api
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40314603
It's got its own web sites.  None of my experiences with SOAP (of any sort) have been good at all.  This is a pretty universal condition.  Most of the major internet players have abandoned SOAP because of all the trouble it causes for developers.  Some links that you may want to explore...
http://sourceforge.net/projects/nusoap/
https://code.google.com/p/nusoap-for-php5/issues/list
http://www.scottnichol.com/nusoapintro.htm
http://www.nusphere.com/php_script/nusoap.htm
http://www.greenacorn-websolutions.com/php/working-with-nusoap.php
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question