Solved

soapenv VS soap

Posted on 2014-09-06
6
751 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
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.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
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…
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…
The viewer will learn how to dynamically set the form action using jQuery.

810 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