I have been trying to add a header to SOAP request as follows
<soapenv:Header>
<UsernameToken xmlns="http://test.com/webservices">username</UsernameToken>
<PasswordText xmlns="http://test.com/webservices">password</PasswordText>
<SessionType xmlns="http://test.com/webservices">None</SessionType>
</soapenv:Header>
I have found suggestions to use SoapHeader to include header values, but introduces another level such as
<soapenv:Header>
<CustomHeader>
<UsernameToken xmlns="http://test.com/webservices">username</UsernameToken>
<PasswordText xmlns="http://test.com/webservices">password</PasswordText>
<SessionType xmlns="http://test.com/webservices">None</SessionType>
</CustomHeader>
</soapenv:Header>
Can anyone suggest how I can form a request without CustomHeader.
Try to use this one
private static void Main()
{
using (var client = new ServiceClient())
using (var scope = new OperationContextScope(client.InnerChannel))
{
MessageHeader usernameTokenHeader = MessageHeader.CreateHeader("UsernameToken",
"http://test.com/webservices", "username");
OperationContext.Current.OutgoingMessageHeaders.Add(usernameTokenHeader);
MessageHeader passwordTextHeader = MessageHeader.CreateHeader("PasswordText",
"http://test.com/webservices", "password");
OperationContext.Current.OutgoingMessageHeaders.Add(passwordTextHeader);
MessageHeader sessionTypeHeader = MessageHeader.CreateHeader("SessionType",
"http://test.com/webservices", "None");
OperationContext.Current.OutgoingMessageHeaders.Add(sessionTypeHeader);
string result = client.GetData(1);
Console.WriteLine(result);
}
Console.ReadKey();
}
The Service Trace viewer shows following
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<UsernameToken xmlns="http://test.com/webservices">username</UsernameToken>
<PasswordText xmlns="http://test.com/webservices">password</PasswordText>
<SessionType xmlns="http://test.com/webservices">None</SessionType>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:13332/Service1.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService/GetData</Action>
</s:Header>
</s:Envelope>
Take a look OperationContextScope for more info
Related
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"
So I am working on an internal project where I am consuming a Java based SOAP Web Service from a WinForm application using a WCF Service Reference interface. (This is something new for me so I apologize if I not totally using the right terminology, etc.) I am sending my request over to the service and I am getting a response, although it has taken some hoop jumping to get there. The format of the response is what is causing me some problems in that it has excessive namespaces and the response size can get large.
I hope someone can point me to a simple solution / setting to reduce the excess.
A few things that I have no control over: The interface is via HTTP (not HTTPS) and security is handled via an App Key/ID mechanism using the a SOAP Security Header and client certificates. The server WSDL does not indicate that WSSE is required in the SOAP Header so the header is being overwritten by the security one prior to the send.
All items below are actual code structure and SOAP request/response format but have been changed to generic items. Also, the "response" is greatly reduced in size. With the right request parameters, a response is over 64k in length.
The SoapUI Request 1 example built with the WSDL load looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pric="http://xmlns.example.com/system/pricing" xmlns:ns="http://xmlns.example.com/system/pricing/shared/3.1.1">
<soapenv:Header/>
<soapenv:Body>
<pric: PricingRequest majorVersion="2" minorVersion="1">
<pric:version>?</pric:version>
<pric:timestamp>?</pric:timestamp>
<!--1 or more repetitions:-->
<pric:acctType>
<!--You have a CHOICE of the next 2 items at this level-->
<pric:customerNbr>?</pric: customerNbr >
<pric:accountNbr>?</pric:accountNbr>
</pric: acctType >
<!--1 to 3 repetitions:-->
<pric:system>?</pric: system >
<pric:source>?</pric:source>
<pric:searchItems>
<pric:purchaseDate>?</pric: purchaseDate >
<!--Zero or more repetitions:-->
<pric:service>
<ns:system>?</ns:system>
<ns:serviceType>?</ns:serviceType>
<!--Optional:-->
<ns:serviceDesc>?</ns:serviceDesc>
<!--Optional:-->
<ns:billingType>?</ns:billingType>
<!--Optional:-->
<ns:effectiveDate>?</ns:effectiveDate>
<!--Optional:-->
<ns:expirationDate>?</ns:expirationDate>
<!--Optional:-->
</pric:service>
</pric: searchItems >
</pric: PricingRequest >
</soapenv:Body>
</soapenv:Envelope>
The app.config Service Model - I added the maxReceivedMessageSize in order to handle the large responses:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PricingServiceSoap11" maxReceivedMessageSize="256000" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://pricing-websvc.example.com:60000/PricingService"
binding="basicHttpBinding" bindingConfiguration="PricingServiceSoap11"
contract="pricingSvcRef.PricingService" name="PricingServiceSoap11" />
</client>
</system.serviceModel>
Code to consume service:
pricingSvcRef.PricingClient pricing = new pricingSvcRef.PricingClient();
var reqInfo = new InspectorBehavior();
pricing.Endpoint.Behaviors.Add(reqInfo);
pricingSvcRef.PricingRequest request = new pricingSvcRef.PricingRequest();
request.majorVersion = 2;
request.minorVersion = 1;
request.version = pricingSvcRef.PricingRequestVersion.Ver1;
request.timestamp = DateTime.Now;
request.acctType = new pricingSvcRef.PricingRequestAcctType[1];
request.acctType[0] = new pricingSvcRef.GetPricingRequestAcctype();
request.acctType[0].Item = txtAcctNo.Text.Trim();
request.system = "Pricing";
request.source = "MyApp";
List<pricingSvcRef.pricingService> svcList = new List<pricingSvcRef.pricingService>();
svcList.Add(
new pricingSvcRef.pricingService
{
system = txtSystem.Text.Trim(),
serviceType = Convert.ToInt32(txServiceType.Text.Trim(),
serviceDesc = txtService.Text.Trim(),
billingType = Convert.ToInt32(txBillingType.Text.Trim(),
effectiveDate = dateEffective.Value,
expirationDate = dateExpiration.Value
});
pricingSvcRef.PricingRequestSearchItems srchItems = new pricingSvcRef.PricingRequestSearchItems
{
purchaseDate = DateTime.Now;
service = svcList.ToArray(),
};
request.searchItems = srchItems;
pricingSvcRef.PricingResponse response = null;
try
{
response = eddSvcRef.GetPricing(request);
}
catch (Exception ex)
{
string msg = "Msg: " + ex.Message;
if ((ex.InnerException != null) && (ex.InnerException.Message.Trim().Length > 0))
msg = msg + "\r\n\r\nInner Msg: " + ex.InnerException.Message.Trim();
MessageBox.Show(msg);
}
SOAP Request that is generated:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>v1:APP1234567:SfPLRHKdXWWqW7mdOdk+gTABVo+y4VZR7UqLHWibVD73jaI0IL9FT4PMgAVAxGsa83P/aon61GuS+IZnuVjRHR4hJgyMuCvtI07QtNaSdwEyw9Lw/Iewm+098fkMYK2pflV7w6hn0U2A9/wzuQS/vfWe53vhGSX1zfhuo6AygKA=:APP1234567</wsse:Username>
</wsse:UsernameToken>
</Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PricingRequest majorVersion="2" minorVersion="1" xmlns="http://xmlns.example.com/system/pricing">
<version>1.0.0</version>
<timestamp>2019-03-25T09:46:26.7337264-05:00</timestamp>
<acctType>
<accountNbr>123456789</accountNbr>
</acctType>
<system>Pricing</system>
<source>MyApp</source>
<searchItems>
<purchaseDate>2019-03-25</purchaseDate>
<service>
<system xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">MyPricing</system>
<serviceType xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">1000</serviceType>
<serviceDesc xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">Service Description</serviceDesc>
<billingType xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">1234</billingType>
<effectiveDate xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">2019-01-01</effectiveDate>
<expirationDate xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">2019-12-31</expirationDate>
</service>
</searchItems>
</PricingRequest>
</s:Body>
</s:Envelope>
SOAP Response in application:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<PricingResponse xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1" xmlns:ns2="http://xmlns.example.com/system/pricing">
<pricingContainer xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">
<version xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">1.0.0</version>
<timestamp xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">2019-03-25T14:46:28.876Z</timestamp>
<source xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">MyApp</source>
<status xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">
<code xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">0000</code>
<description xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">SUCCESS</description>
</status>
<acctType xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">
<accountNbr xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">123456789</accountNbr>
</acctType>
<system xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">Pricing</system>
<serviceDetail xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">
<valid xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">Y</valid>
<system xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">MyPricing</system>
<serviceType xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">1000</serviceType>
<serviceDesc xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">Service Description</serviceDesc>
<billingType xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">1234</billingType>
<effectiveDate xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">2019-01-01</effectiveDate>
<expirationDate xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">2019-12-31</expirationDate>
<pricingRate xmlns="http://xmlns.example.com/system/pricing/shared/3.1.1">100</pricingRate>
</serviceDetail>
</pricingContainer>
</PricingResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So even though namespaces are returning as part of the PricingResponse element, they are also on each child item below that.
UPDATE: I thought SoapUI responses were coming back w/o the excessive namespace items on each element but I have now determined using Wireshark and SoapUI Raw display that this not the case.
Is there anyway to request from the WCF Interface to the Java Web Service that the response uses namespace prefixes rather than having a namespace on almost every response element? Obviously I am going to keep digging at it but any help / guidance would be appreciated.
Thanks
I'm have a problem with a SOAP header created in my C# client. The server is sending back the error
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope" />
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:MustUnderstand</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}To] are not understood.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I have been under the impression that I have been removing all SOAP headers with the following code.
internal class CustomMessageInspector : IEndpointBehavior, IClientMessageInspector
{
public object BeforeSendRequest( ref Message request, IClientChannel channel )
{
request.Headers.Clear();
return null;
}
...
}
However, after activating System.ServiceModel.MessageLogging in the app.config, (WCF - Inspect the messages being sent/received?), I see that the server is correct - lo and behold there is a "To" header with "mustUnderstand" set to 1 :
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:To s:mustUnderstand="1">https://ws-single-transactions-int-bp.nmvs.eu:8443/WS_SINGLE_TRANSACTIONS_V1/SinglePackServiceV30</a:To>
</s:Header>
Any thoughts how I can prevent this header from being added?
Many thanks.
In case it helps anybody else, I have found a solution. In fact Nicolas Giannone provided all the necessary code here WSHttpBinding in .NetStandard or .NET core . What we can do is to replace the WSHttpBinding with a custom binding based on the WSHttpBinding, and then replace the TextMessageEncodingBindingElement with one with no addressing. Here's the code :
string endPoint = myConfig.SinglePackServicesEndPoint;
//Defines a secure binding with certificate authentication
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
// create a new binding based on the existing binding
var customTransportSecurityBinding = new CustomBinding( binding );
// locate the TextMessageEncodingBindingElement - that's the party guilty of the inclusion of the "To"
var ele = customTransportSecurityBinding.Elements.FirstOrDefault( x=>x is TextMessageEncodingBindingElement );
if( ele != null )
{
// and replace it with a version with no addressing
// replace {Soap12 (http://www.w3.org/2003/05/soap-envelope) Addressing10 (http://www.w3.org/2005/08/addressing)}
// with {Soap12 (http://www.w3.org/2003/05/soap-envelope) AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)}
int index = customTransportSecurityBinding.Elements.IndexOf( ele );
var textBindingElement = new TextMessageEncodingBindingElement
{
MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};
customTransportSecurityBinding.Elements[index] = textBindingElement;
}
I am trying to call a method in a WCF service. I can hit the method and it can receive all the parameters except an array of integers. The content of my calls looks like:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action>Test/TestContract/DeletePersons</a:Action>
<a:To>#Location</a:To>
</s:Header>
<s:Body>
<DeletePersons xmlns="Test">
<groupname>connStringDatabase</groupname>
<username>#Username</username>
<password>#Password</password>
<insurer>#Insurer</insurer>
<onlyfromself>false</onlyfromself>
<identification_number/>
<initials/>
<firstname>#FirstName</firstname>
<name>#LastName</name>
<gender/>
<dateofbirth/>
<personIds>
<int>123</int>
</personIds>
</DeletePersons>
</s:Body>
</s:Envelope>
The method in the contract of the service looks like this:
[ServiceContract(Namespace = "Test")]
public interface TestContract
{
[OperationContract]
TestResponse DeletePersons(string groupname, string username, string password, string insurer, List<int> personIds);
}
As I said, all the parameters (strings) are received correctly while the personIds array is received but it's empty. How should encode it into the XML request? Thanks in advance!
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>