Solved

Change Namespace SOAP

Posted on 2014-09-10
3
458 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 108

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
The viewer will learn how to count occurrences of each item in an array.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now