Unable to send SOAP headers to c# WS - c#

i try to connect to web service. i success to get to the function 'AppendChunk', but with out headers, please Someone, tell me what i am doing worng?
the xml i have to send look like that:
<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:Header>
<WSCredential xmlns="http://cellact.com/">
<Username>string</Username>
<Password>string</Password>
<Company>string</Company>
</WSCredential>
</soap:Header>
<soap:Body>
<AppendChunk xmlns="http://cellact.com/">
<FileName>string</FileName>
<buffer>base64Binary</buffer>
<Offset>long</Offset>
</AppendChunk>
</soap:Body>
</soap:Envelope>
this is the code:
require_once('/root/nusoap-0.9.5/lib/nusoap.php');
function GetFileContents( $filename ) {
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
return $contents;
}
$parameters = array("stream" => GetFileContents("bookSmall.csv"));
$client = new nusoap_client('http://cellactprolocal.net/mews/WSExt2.asmx?wsdl',true);
$params = array(
'FileName' => "book2.csv",
'buffer' => $parameters,
'Offset' => 0
);
$ns = "http://cellact.com";
$headers = "<WSCredential ><ns1:Username xmlns:ns1=\"$ns\">xxx</ns1:Username>
<ns2:Password xmlns:ns2=\"$ns\">xxx/</ns2:Password>
<ns3:Company xmlns:ns3=\"$ns\">xxx</ns3:Company>
</WSCredential >";
$client->setHeaders($headers);
$result = $client->call('AppendChunk', $params, $ns);
print_r($result);

You should encode your file before sending, first add function
function GetFileContents( $filename ) {
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
return $contents;
}
Then change in the code :
$decodeContent = base64_encode(GetFileContents("your file name"));
$params = array(
'FileName' => "test.csv",
'buffer' => $decodeContent,
'Offset' => 0
);

Related

XPath request matching with WireMock.net

I want to send a mock response from my service when the request matches on these characteristics:
URL matches with /BATConnectWS/services/CoverApplication
The HTTP method matches with POST
The XPath matcher must match an amount of 5000
Code setup:
var server = FluentMockServer.Start(new FluentMockServerSettings
{
Urls = new[] { "http://+:8099" },
StartAdminInterface = true,
Logger = new WireMockConsoleLogger()
});
server
.Given(Request.Create().WithPath("/*")).AtPriority(10)
.RespondWith(Response.Create()
.WithProxy("https://TheRealService.com/"));
server
.Given(Request.Create().WithPath("/BATConnectWS/services/CoverApplication").UsingPost()
.WithBody(new XPathMatcher(#"//applyForCreditLimit/application/RequestedAmount/text() = 5000")))
.AtPriority(1)
.RespondWith(Response.Create()
.WithHeader("Content-Type", "text/xml; charset=utf-8")
.WithCallback(req =>
{
return CoverApplicationResponseBuilder.CreateResponse(req);
}));
The request message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>urn:applyForCreditLimit</wsa:Action>
<wsa:MessageID>urn:uuid:6da4a592-90a0-4623-8c71-1e685cbdac33</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://localhost:58070/BATConnectWS/services/CoverApplication</wsa:To>
<wsse:Security soap:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-6befddc7-4e4f-4a76-a203-49b729bd483a">
<wsu:Created>2019-10-15T08:22:37Z</wsu:Created>
<wsu:Expires>2019-10-15T08:27:37Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-x-x-x-x-x">
<wsse:Username>xxx</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxx</wsse:Password>
<wsse:Nonce>xxx</wsse:Nonce>
<wsu:Created>2019-10-15T08:22:37Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<applyForCreditLimit xmlns="http://atradius.com/connect/_2007_08/">
<application>
<CustomerId xmlns="">1234</CustomerId>
<PolicyNr policyTypeIdentifier="NON_LEG" xmlns="">
<Id>5678</Id>
</PolicyNr>
<ExternalCoverId xmlns="">9101112</ExternalCoverId>
<CustomerReference xmlns="">areference</CustomerReference>
<Buyer registeredOffice="SYMPH" xmlns="">
<id xmlns="http://atradius.com/organisation/_2007_08/type/">13141516</id>
<countryTypeIdentifier xmlns="http://atradius.com/organisation/_2007_08/type/">AUT</countryTypeIdentifier>
</Buyer>
<RequestedAmount xmlns="">5000</RequestedAmount>
<CurrencyCode xmlns="">EUR</CurrencyCode>
</application>
</applyForCreditLimit>
</soap:Body>
</soap:Envelope>
Without the XPathMatcher the mocked response will be sent.
With the XPatchMatcher the real service will be called (pass through), because there was no WithBody match on the content.
What should the XPath query be like to match on the amount of 5000, in the RequestedAmount element?
This has to do with the namespaces used maybe?
If you are only interested if any RequestedAmount element with value 5000 exists in the soap message, you could just use this I think:
#"//RequestedAmount/text() = 5000"

XML serialized from classes created with xsd is not correct

I have an XML file (it's a SOAP request to an SAP ME Service).
The file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:me="http://sap.com/xi/ME">
<soapenv:Header />
<soapenv:Body>
<me:ShopOrderByBasicDataQuery_sync>
<me:ShopOrderByBasicDataQuery>
<me:ShopOrder>BOXBUILD_LASER_TEST</me:ShopOrder>
<me:SiteRef>
<me:Site>TEST1</me:Site>
</me:SiteRef>
</me:ShopOrderByBasicDataQuery>
</me:ShopOrderByBasicDataQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Using Paste Special I used Paste XML as Classes and got a number of classes.
I the created a new Envelope object
Envelope shoporder = new Envelope();
EnvelopeBody shoporderBody = new EnvelopeBody();
ShopOrderByBasicDataQuery_sync shoporderSync = new ShopOrderByBasicDataQuery_sync();
ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuery shoporderDataQuery = new ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuery();
shoporderSync.ShopOrderByBasicDataQuery = shoporderDataQuery;
shoporderDataQuery.ShopOrder = "BOXBUILD_LASER_TEST";
shoporderDataQuery.SiteRef = new ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuerySiteRef();
shoporderDataQuery.SiteRef.Site = "TEST1";
shoporderSync.ShopOrderByBasicDataQuery = shoporderDataQuery;
shoporderBody.ShopOrderByBasicDataQuery_sync = shoporderSync;
shoporder.Body = shoporderBody;
string tmp = (string)SoapHelper.SerializeToXmlString(shoporder);
The string tmp contains this (after a bit of formatting)
<?xml version="1.0" encoding="utf-16"?>
<Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<ShopOrderByBasicDataQuery_sync xmlns="http://sap.com/xi/ME">
<ShopOrderByBasicDataQuery>
<ShopOrder>BOXBUILD_LASER_TEST</ShopOrder>
<SiteRef>
<Site>TEST1</Site>
</SiteRef>
</ShopOrderByBasicDataQuery>
</ShopOrderByBasicDataQuery_sync>
</Body>
</Envelope>
Which is not a correct file! What have I done wrong?

Non-wsdl SOAP request in PHP

I need to post SOAP request to some server.
I know exactly that the right example of SOAP request as follows:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateOrderBroker xmlns="http://tempuri.org/">
<shortApp xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:PIB>John Doe</a:PIB>
<a:agreeId>3155</a:agreeId>
<a:formId>55</a:formId>
<a:stateCode>1234567890</a:stateCode>
<a:telephone>1511528945</a:telephone>
</shortApp>
</CreateOrderBroker>
</s:Body>
</s:Envelope>
Also I have working C# example:
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
public EndpointAddress EndPointAddr {
get { return
new EndpointAddress("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl");
}
}
private void btnSend_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
ServicePointManager.Expect100Continue = false;
ServiceICreditTest.CreateOrderResponse response = new CreateOrderResponse();
ScroogeSiteGist client = new ScroogeSiteGist(Binding(), EndPointAddr);
shortApplicationBroker shortAp = new shortApplicationBroker()
{
agreeId = 3155,
PIB = "John Doe",
stateCode = "1234567890",
formId = 55,
telephone = "1511528945"
};
//response = client.CreateOrder("1012021013");
response = client.CreateOrderBroker(shortAp);
txtText.Text = string.Format("id = {0} ErrorId = {1}", response.OrderId, response.ReturnValue);
}
}
I'm trying to make same code in PHP 5.3:
<?php
$client = new SoapClient("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl", array('soap_version' => SOAP_1_1, 'trace' => 1));
$params = array(
'agreeId' => 3155,
'PIB' => 'John Doe',
'stateCode' => '3289013768',
'formId' => 55,
'telephone' => '0661254877'
);
$client->CreateOrderBroker($params);
But request and callback from this code is next:
<?php
...
echo "REQUEST:<pre>".htmlspecialchars($client->__getLastRequest()) ."</pre>";
echo "CALLBACK:<pre>".htmlspecialchars($client->__getLastResponse())."</pre>";
REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body><ns1:CreateOrderBroker/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
CALLBACK:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body><CreateOrderBrokerResponse xmlns="http://tempuri.org/"><CreateOrderBrokerResult xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:OrderId>0</a:OrderId>
<a:ReturnValue>Object reference not set to an instance of an object.</a:ReturnValue>
</CreateOrderBrokerResult>
</CreateOrderBrokerResponse>
</s:Body>
</s:Envelope>
It seems that body of request is empty.
What does it mean? If call made in wsdl-mode and request body is empty then wsdl-schema is broken, right?
If wsdl is broken what is the way to construct initial right SOAP request manually? Can anyone give an example?
Moreover, the data given in initial right SOAP request is enough to construct this request manually? Or I need some extra (namespaces, etc.)
Try the following code:
$client = new SoapClient("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl", array('soap_version' => SOAP_1_1, 'trace' => 1));
class shortApp {
function __construct()
{
$this->agreeId = 3155;
$this->PIB = 'John Doe';
$this->stateCode = '3289013768';
$this->formId = 55;
$this->telephone = '0661254877';
}
}
$sa = new shortApp();
$shortApp = new SoapVar($sa, SOAP_ENC_OBJECT, 'shortApp', 'http://soapinterop.org/xsd');
$response = $client->CreateOrderBroker(new SoapParam($shortApp, 'shortApp'));
This code should give you the following request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://soapinterop.org/xsd" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:CreateOrderBroker>
<shortApp xsi:type="ns2:shortApp">
<agreeId xsi:type="xsd:int">3155</agreeId>
<PIB xsi:type="xsd:string">John Doe</PIB>
<stateCode xsi:type="xsd:string">3289013768</stateCode>
<formId xsi:type="xsd:int">55</formId>
<telephone xsi:type="xsd:string">0661254877</telephone>
</shortApp>
</ns1:CreateOrderBroker>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

NuSoap Server Works with SoapUI, but not C#.NET 3.5

I'm setting up a web service to accept orders from a third party, and I've been having some troubles some odd errors. I'm running CodeIgniter with a NuSoap server handling the request. They're running C# .NET 3.5 to send the request. Every time they submit the request through their app, it returns an error: "Object Reference not set to an Instance of an object."
I asked them to send me the SOAP request and response, and here they are (unfortunately it's proprietary, so I can't provide all the info and I've changed some names)
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://InspectionService/SendInspectionRequestTPA</Action>
<h:AuthenticateHeader xmlns="http://InspectionService/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://InspectionService/">
<UserName>USERNAME</UserName>
<Password>PASSWORD</Password>
</h:AuthenticateHeader>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SendInspectionRequestTPA xmlns="http://InspectionService/">
<RequesterName>Bob</RequesterName>
<RequesterExt>5555555555</RequesterExt>
<RequesterEmail>email#test.net</RequesterEmail>
<SaleDate>2013-08-04T00:00:00</SaleDate>
<VehicleYear>2010</VehicleYear>
<VehicleMake>MITSUBISHI</VehicleMake>
<VehicleModel>GALANT ES/SE</VehicleModel>
<Mileage>60000</Mileage>
<VIN>12341234123412341</VIN>
<ContractNumber>SEP00001025NVSC</ContractNumber>
<ClaimNumber>C000001061</ClaimNumber>
<InspectionType>Automotive</InspectionType>
<InspectionReason>
<anyType xsi:type="xsd:string">RIGHT FRONT WINDOW IS NOT WORKING</anyType>
<anyType xsi:type="xsd:string">MOTOR SHORTED</anyType>
<anyType xsi:type="xsd:string">REPLACE RIGHT FRONT WINDOW MOTOR</anyType>
<anyType xsi:type="xsd:string">THIS IS A TEST INSPECTION.</anyType>
</InspectionReason>
<RepairSite>CLAIM DEMO DEALER-SEP 2</RepairSite>
<Address1>ADDR</Address1>
<Address2 />
<City>OMAHA</City>
<State>NE</State>
<Zip>68144</Zip>
<Contact>JOE SERVICER</Contact>
</SendInspectionRequestTPA>
</s:Body>
</s:Envelope>
(Note that I removed some sensitive lines in the request and changed others)
And the response:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>... stream ...</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
(Edit: This was part of our issue, in that this debug response was truncated by the company--so we never got the actual debug info from their side)
The thing here is that this request works perfectly (read: as expected) when submitted through SOAPUI. Here's the code from my CodeIgniter Controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Carwash extends CI_Controller
{
public function __construct()
{
parent::__construct();
error_reporting(0);
ini_set('display_errors','Off');
$ns = 'http://'.$_SERVER['HTTP_HOST'].'/carwash';
$ep = 'http://'.$_SERVER['HTTP_HOST'].'/carwash';
$this->ns = $ns;
$this->load->library("Nusoap_library"); // load nusoap toolkit library in controller
$this->nusoap_server = new soap_server(); // create soap server object
$this->nusoap_server->configureWSDL("EACCarwash", $this->ns, $ep); //, "rpc", 'http://schemas.xmlsoap.org/soap/http', array(),); // wsdl configuration
$this->nusoap_server->wsdl->schemaTargetNamespace = $ns; // server namespace
$this->nusoap_server->namespaces['soap'] ='http://schemas.xmlsoap.org/soap/encoding/';
$this->load->model('carwash_model');
}
public function index()
{
$fi_input = array(
"RequesterName" => "xsd:string",
"RequesterExt" => "xsd:string",
"RequesterEmail" => "xsd:string",
"ContractHolder" => "xsd:string",
"SaleDate" => "xsd:dateTime",
"SaleOdometer" => "xsd:string",
"VehicleYear" => "xsd:string",
"VehicleMake" => "xsd:string",
"VehicleModel" => "xsd:string",
"Mileage" => "xsd:string",
"VIN" => "xsd:string",
"ContractNumber" => "xsd:string",
"ClaimNumber" => "xsd:string",
"InspectionType" => "xsd:string",
"InspectionReason" => "xsd:struct",
"RepairSite" => "xsd:string",
"Address1" => "xsd:string",
"Address2" => "xsd:string",
"City" => "xsd:string",
"State" => "xsd:string",
"Zip" => "xsd:string",
"Phone" => "xsd:string",
"Contact" => "xsd:string",
"TpaCode" => "xsd:string"
);
$fi_return = array(
"SendInspectionRequestTPAResult" => "xsd:string"
);
$this->nusoap_server->register('SendInspectionRequestTPA',
$fi_input,
$fi_return,
"urn:SOAPServerWSDL",
"urn:".$this->ns."/SendInspectionRequestTPA",
"rpc",
"encoded",
"DESCRIPTION HERE",
"http://schemas.xmlsoap.org/soap/encoding/");
function SendInspectionRequestTPA($req_name, $req_ext, $req_email, $contract_holder, $sale_date, $sale_odometer, $v_year, $v_make, $v_model, $mileage, $vin, $contract_no, $claim_no, $insp_type, $insp_reason, $repair_site, $addr1, $addr2, $city, $state, $zip, $phone, $contact_name, $tpa_code)
{
$CI =& get_instance();
if($CI->check_creds() == FALSE)
{
return new soap_fault('Client','','Not authorized');
}
else
{
if(!$req_name){ return new soap_fault('Client','','Requester Name Required');}
if(!$sale_date){ return new soap_fault('Client','','Sale Date Required');}
if(!$v_year){ return new soap_fault('Client','','Vehicle Year Required');}
if(!$v_make){ return new soap_fault('Client','','Vehicle Make Required');}
if(!$v_model){ return new soap_fault('Client','','Vehicle Model Required');}
if(!$mileage){ return new soap_fault('Client','','Mileage Required');}
if(!$contract_no){ return new soap_fault('Client','','Contract Number Required');}
if(!$claim_no){ return new soap_fault('Client','','Claim Number Required');}
if(!$insp_type){ return new soap_fault('Client','','Inspection Type Required');}
if(!$insp_reason){ return new soap_fault('Client','','Inspection Reason Required');}
if(!$repair_site){ return new soap_fault('Client','','Repair Site Required');}
if(!$contact_name){ return new soap_fault('Client','','Contact Required');}
if(!$tpa_code){ return new soap_fault('Client','','TPA Code Required');}
$id = $CI->carwash_model->add_fni_insp($req_name, $req_ext, $req_email, $contract_holder, $sale_date, $sale_odometer, $v_year, $v_make, $v_model, $mileage, $vin, $contract_no, $claim_no, $insp_type, $insp_reason, $repair_site, $addr1, $addr2, $city, $state, $zip, $phone, $contact_name, $tpa_code) or die(new soap_fault('Server','','Error Processing Request'));
return (string) ((int) $id);
//else{return new soap_fault('Server', '','Error processing request');}
}
}
$this->soapy = file_get_contents("php://input");
$this->nusoap_server->service($this->soapy);
}
public function hookTextBetweenTags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)<\/$tagname>/i";
preg_match($pattern, $string, $matches);
return $matches[1];
}
public function check_creds()
{
if(isset($this->soapy))
{
$sUsername = $this->hookTextBetweenTags($this->soapy, 'Username');
$sPassword = $this->hookTextBetweenTags($this->soapy, 'Password');
$verify = $this->carwash_model->check_fni_user($sUsername, $sPassword);
//var_dump($verify);
return $verify;
}
}
}//end class
I will confess that I'm relatively new with setting up SOAP Servers, so if something's really stupid or out of place, I would really love to hear about that, too.
When I googled the "Object Reference not set to an instance of an object" error, it seems that essentially the server was expecting an object and didn't get one. The only place that would happen is the "inspectionreason" field, which is well-formed in their request. That's pretty much the only thing that I could pinpoint as to where that error comes from. But since it works with SOAPUI, I'm inclined to think that the error is related to the request--and not the server.
Does anyone see any glaring errors? Or is there something with NuSoap that I should be configuring?
Let me know if I can provide any more details. Thanks!

SOAP Communication between PHP client and windows service results in NullReferenceException

If i test the Service with SoapUi the operation scucceds, but if implement the Soap Client with PHP the parameters are allways emty and i get an NullReferenceException.
<?php
$options = array();
$options['classmap']['Abonnent'] = 'RequestType';
$client = new SoapClient('wsdllink',$options);
class RequestType
{
public $Email;
public $Nachname;
public $Passwort;
public $Vorname;
}
$abo = new RequestType;
$abo->Email = 'email';
$abo->Nachname = 'lastname';
$abo->Passwort = 'passwort';
$abo->Vorname = 'firstname';
try {
$result = $client->Abonnieren($abo);
} catch(SoapFault $e) {
echo "Request :\n". ($client->__getLastRequest()). "\n";
echo "Response :\n". ($client->__getLastResponseHeaders()). "\n";
echo "Response :\n". ($client->__getLastResponse()). "\n";
echo($e->getMessage());
} catch(Exception $e) {
echo $e->getMessage();
}
?>
var_dump($client->__getFunctions())
array(2) {
[0]=>
string(53) "AbonnierenResponse Abonnieren(Abonnieren $parameters)"
[1]=>
string(53) "RegisterIBResponse RegisterIB(RegisterIB $parameters)"
}
var_dump($client->__getTypes())
array(8) {
[0]=>
string(87) "struct Abonnent {
string Email;
string Nachname;
string Passwort;
string Vorname;
}"
[1]=>
string(41) "struct Abonnieren {
Abonnent abonnent;
}"
[2]=>
string(56) "struct AbonnierenResponse {
boolean AbonnierenResult;
}"
[3]=>
string(41) "struct RegisterIB {
Abonnent abonnent;
}"
[4]=>
string(56) "struct RegisterIBResponse {
boolean RegisterIBResult;
}"
[5]=>
string(8) "int char"
[6]=>
string(17) "duration duration"
[7]=>
string(11) "string guid"
}
XML from SoupUI
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:prm="http://schemas.datacontract.org/2004/07/PRMarketService">
<soapenv:Header/>
<soapenv:Body>
<tem:Abonnieren>
<tem:abonnent>
<prm:Email>email</prm:Email>
<prm:Nachname>lastname</prm:Nachname>
<prm:Passwort>passwort</prm:Passwort>
<prm:Vorname>firstname</prm:Vorname>
</tem:abonnent>
</tem:Abonnieren>
</soapenv:Body>
</soapenv:Envelope>
XML from PHP Client
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.datacontract.org/2004/07/PRMarketService"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="http://tempuri.org/">
<SOAP-ENV:Body>
<ns2:Abonnieren xsi:type="ns1:Abonnent">
<ns1:Email>email</ns1:Email>
<ns1:Nachname>lastname</ns1:Nachname>
<ns1:Passwort>passwort</ns1:Passwort>
<ns1:Vorname>firstname </ns1:Vorname>
</ns2:Abonnieren>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Compare messages sent by SoapUI and PHP's SoapClient, for example using Fiddler. If I recall correctly, you'll have to wrap the XML body PHP sends in a root element named after the appropriate SOAPAction.
Something like this:
class AbonnierenRequest
{
public $Abbonent;
}
class Abonnent
{
public $Email;
public $Nachname;
public $Passwort;
public $Vorname;
}
$request = new AbonnierenRequest();
$request->Abonnent = new Abonnent();
$request->Abonnent->Email = 'email';
$request->Abonnent->Nachname = 'lastname';
$request->Abonnent->Passwort = 'passwort';
$request->Abonnent->Vorname = 'firstname';
$result = $client->Abonnieren($request);

Categories

Resources