Create Web Service for get soap messages - c#

Actually, I had to make the request.
But service providers will not test sending any messages until after going through certain steps
So I need to create a website to test the messages I send.
How can I create a web service to receive soap messages below?
Content-ID: <ebxhmheader111#example.com>
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
http://www.oasis-open.org/committees/ebxml-msg/schema/envelope.xsd
http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd
http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
<SOAP:Header>
<eb:MessageHeader SOAP:mustUnderstand="1" eb:version="2.0">
<eb:From>
<eb:PartyId>urn:duns:123456789</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId>urn:duns:912345678</eb:PartyId>
</eb:To>
<eb:CPAId>20001209-133003-28572</eb:CPAId>
<eb:ConversationId>20001209-133003-28572</eb:ConversationId>
<eb:Service>urn:services:SupplierOrderProcessing</eb:Service>
<eb:Action>NewOrder</eb:Action>
<eb:MessageData>
<eb:MessageId>20001209-133003-28572#example.com</eb:MessageId>
<eb:Timestamp>2001-02-15T11:12:12</eb:Timestamp>
</eb:MessageData>
</eb:MessageHeader>
</SOAP:Header>
<SOAP:Body>
<eb:Manifest eb:version="2.0">
<eb:Reference xlink:href="cid:ebxmlpayload111#example.com" xlink:role="XLinkRole" xlink:type="simple">
<eb:Description xml:lang="en-US">Purchase Order 1</eb:Description>
</eb:Reference>
</eb:Manifest>
</SOAP:Body>
</SOAP:Envelope>
--BoundarY
Content-ID: <ebxmlpayload111#example.com>
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<purchase_order>
<po_number>1</po_number>
<part_number>123</part_number>
<price currency="USD">500.00</price>
</purchase_order>
--BoundarY––

Related

Handling different SOAP response element

I have a simple WCF that fetches two values.
In SoapUi I have this result
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<nHeartbeatId>?</nHeartbeatId>
<strSystemID>?</strSystemID>
</soap:Body>
</soap:Envelope>`
But I need to be like this Add mar:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mar="abc">
<soap:Header/>
<soap:Body>
<mar:nHeartbeatId>?</mar:nHeartbeatId>
<mar:strSystemID>?</mar:strSystemID>
</soap:Body>
</soap:Envelope>

Using SOAP in C#

How can I access to a web service using SOAP in C# and get data from it? The request template is as follows:
POST /webservice/TsePublicV2.asmx HTTP/1.1
Host: service.tsetmc.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<MarketValue xmlns="http://tsetmc.com/">
<UserName>string</UserName>
<Password>string</Password>
</MarketValue>
</soap12:Body>
</soap12:Envelope>
The Response template is as follows:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<MarketValueResponse xmlns="http://tsetmc.com/">
<MarketValueResult>decimal</MarketValueResult>
</MarketValueResponse>
</soap12:Body>
</soap12:Envelope>

provide data into <tag> xml xml </tag> for a C# web service

I have a method in C# .NET 4.0 web service which accepts DataTable as on of the ByVal parameter.
This method is now being used in an xml application.
So, in the place of the datatable, I am getting as <Meta> xml xml </Meta>.
How should I pass the data in the form of xml to be able to use by datatable within the xml below?
I haven't found proper solutions for this on web.
POST /MyService/service.asmx HTTP/1.1
Host: xxxxxxxxxxxxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Upload"
<?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>
<Upload xmlns="http://tempuri.org/">
<IndexKey>string</IndexKey>
<YoMoney_Key>string</YoMoney_Key>
<buffer>base64Binary</buffer>
<strDocType>string</strDocType>
<append>boolean</append>
<revtype>string</revtype>
<strScanDateTime>string</strScanDateTime>
<UserID>string</UserID>
<Meta>xmlxml</Meta>
</Upload>
</soap:Body>
</soap:Envelope>

Is there some way I can send the SoapAction header within the xml request itself

I can send the Basic Authentication request within the xml itself without even writing something like
request.headers.add("");
and adding like this
<?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:Header>
<Authentication xmlns="http://tempuri.org/">
<Password>string</Password>
<UserName>string</UserName>
</Authentication>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Similarly I want to set the SOAPAction within the header xml itself instead of writing
request.headers.add("SOAPAction","someAction");
Somewhat like this
<?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:Header>
<SOAPAction>http://abc/xyz/test</SOAPAction>
<Authentication xmlns="http://tempuri.org/">
<Password>string</Password>
<UserName>string</UserName>
</Authentication>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Please guide me that How it can be achieved?

Remove the response wrapper from web service response?

Is it possible to remove the what appears to be automatic notificationRequestResponse node from the response?
<?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>
<notificationRequestResponse xmlns="...">
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</notificationRequestResponse>
</soap:Body>
</soap:Envelope>
I need to return the below:
<?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>
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</soap:Body>
</soap:Envelope>
I want the notificationResponse to be the root of the response!
The WebMethod currently has no logic but:
return new notificationResponse()
Where is the notificationRequestResponse coming from? I can rename it using WebMethod SoapDocumentMethod(ResponseElementName="new name") but I want it gone. Working to a provided spec and have no choice.
Appreciated.
Found the answer...
SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)

Categories