Solved

soapenv VS soap

Posted on 2014-09-06
6
528 Views
Last Modified: 2016-10-25
Hello,

I am trying to send an XML SOAP request using cURL.  The request works, but it does not post any of the XML.  I began to use the following script to debug.

libxml_use_internal_errors(true);
$sxe = simplexml_load_string($soap_request);
print_r($sxe);
if (!$sxe) {
    echo "Failed loading XML\n";
    foreach(libxml_get_errors() as $error) {
        echo "\t", $error->message;
    }
}

Open in new window


If I use

$soap_request = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<soapenv: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/">
<soapenv:Body>
<RemittanceRequest>
<RequestType>BranchListRequest</RequestType>
<agent>BWS</agent>
<userid>wbsuser</userid>
<password>pass@wbs</password>
</RemittanceRequest>
</soapenv:Body>
</soapenv:Envelope>';

Open in new window


I receive no errors with the debugging code, but if I use

$soap_request = "<?xml version=\"1.0\" encoding=\"utf-8\"?><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>    <AuthenticateByWebServiceCode xmlns=\"http://chsportal.primogen-solutions.co.uk/\">      <webServiceCode>xxx1</webServiceCode>    </AuthenticateByWebServiceCode>  </soap:Body></soap:Envelope>";

Open in new window


Everything fails..The only difference is soapenv VS soap.

I am trying to post this to

http://www.dfwebservice.net/DfcsRemittance.asmx?WSDL

using an ACTION of

http://dfwebservice.net/GetBranchListXML

any help getting this working would be greatly appreciated.

Thanks!
0
Comment
Question by:bradley525
  • 3
  • 2
6 Comments
 
LVL 33

Expert Comment

by:Slick812
ID: 40307804
greetings bradley525, , I am not sure how much help I can be for this, I will start by saying that any and ALL workable Soap server exchanges that I have done or know about NEVER use the php cURL( ), which is an HTTP web protocol sever exchange mechanism which is a ONE time request. The server SOAP uses a completely different server protocol, which is a connection , not a request,  you must use the php soap class as in -
    $client = new SoapClient("some.wsdl");
as outlined in the PHP manual -
    http://php.net/manual/en/soapclient.soapclient.php

however, it is my view that any programming language use of SOAP is NOT a simple thing, and in PHP as a SOAP client, , you have to set up ALL of your retrieved soap function parameters in arrays and use those arrays to get the function response from the SOAP function server.

Almost ALL web services that use the SOAP exchange, by necessity have Client code examples (in PHP, ASP, JSP) so developers can use their services as a Client. You need to go to your SOAP web service developers API information pages, and Copy and Paste their PHP SOAP client code examples, and hope you can see what they are doing.

If I have been unclear or not on topic, or you need more info, please ask questions
0
 

Author Comment

by:bradley525
ID: 40307813
Hello thank you for the response, unfortunately the SOAP web service developers do not have any php example code. All they provided was the sample XML request and response.

If I am using php and should not use cURL what should I use?

Thanks
0
 
LVL 33

Expert Comment

by:Slick812
ID: 40308873
I am really not sure what to recommend to you now, As I said, the SOAP was created to do FUNCTIONS in a client computer, that communicate to another Server, and that distant server actually does the the "work" for that function, and then sends back a "result" to the Client side Function, to use the Result data to make the input parameters for another soap Function, and get back another result, for as many functions as needed to finish the work on the Client.

There are Different types of Soap connections, yours has an XML for the namespace and function definitions as a WSDL document here -
    http://www.dfwebservice.net/DfcsRemittance.asmx?WSDL
this is suppose to list all  remote "Class Objects" and their Methods and parameters.

and in the PHP code you might call it as -
    $client = new SoapClient( 'http://www.dfwebservice.net/DfcsRemittance.asmx?WSDL' );
    $paraArry = array ('agent' => 'BWS', 'userid' => 'ad5b2f21c0' 'password' => 'pass@wbs');
    $result = $client->RemittanceRequest($paraArry);

The above is a wild guess on my part for calling the $client->RemittanceRequest( );  method.

I really can NOT, get any relevant info from the WSDL at -
   'http://www.dfwebservice.net/DfcsRemittance.asmx?WSDL'
it uses an Object strategy with the  s:element   that I do not understand and have no time to research, as in this line-
      <s:element name="RemittanceRequestXML">

There is a PHP library called  nusoap.php  that has some SOAP RAD help in it, you can see a Page about it here -
    http://codewalkers.com/c/a/Miscellaneous/Using-SOAP-with-PHP/5/

the W3 Schools has a tutorial for SOAP, here's one page for it -
   http://www.w3schools.com/webservices/ws_soap_body.asp

as I said before, There are few developers that can look at the WSDL and see what the objects and methods and parameters will be in the client code, because of how the namespaces may or may not define complex types and other types. So, the Web Service has to have some way to show HOW to use their web service In a developer API listing. Sorry I can not just show you the correct code, If there is a developer API listing for this service , I will look at it an see if I can get anything.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Accepted Solution

by:
bradley525 earned 0 total points
ID: 40362720
I ended up using a windows server to get this to work..I had to write it in .NET...Nothing above seemed to work.
0
 

Author Closing Comment

by:bradley525
ID: 40372512
The answers in this thread did not work I had to use .NET on a windows server to make SOAP work.
0
 

Expert Comment

by:Donald Duck
ID: 41858630
The second line is incorrect. Here's a correct version:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

11 Experts available now in Live!

Get 1:1 Help Now