Solved

soapenv VS soap

Posted on 2014-09-06
6
821 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 34

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 34

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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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, …
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.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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