Solved

Change Namespace SOAP

Posted on 2014-09-10
3
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

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 110

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

630 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