Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change Namespace SOAP

Posted on 2014-09-10
3
Medium Priority
?
666 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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

670 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