consuming wcf services in android and android-wcf session management - wcf-security

How do i generate the following soap envelope in android in order to consume wcf services...
the following envelope is generated in c# and caught by fiddler2..
<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 s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</a:Action>
<a:MessageID>urn:uuid:7be47300-e1a9-4f16-8d79-8e1bd52974cb</a:MessageID>
<ActivityId CorrelationId="0d0b0e9e-4783-44a6-85ed-2f36eb4ec1c3" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">6e45258f-1a8f-47f1-bed8-78172465df1c</ActivityId>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://test.parkingware.com:6060/Parkingware.Reservation.Service/ReservationService.svc</a:To>
</s:Header>
<s:Body>
<trust:RequestSecurityToken Context="uuid-7843886f-5c12-4843-8ac2-1ccf8636e0a7-1" xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<trust:TokenType>http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct</trust:TokenType>
<trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType>
<trust:KeySize>256</trust:KeySize>
<trust:BinaryExchange ValueType="http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">FgMBAFoBAABWAwFSpZ2WydPrK+SLYmvHk/bH914LbdddJStkVnE3ZLR2swAAGAAvADUABQAKwBPAFMAJwAoAMgA4ABMABAEAABX/AQABAAAKAAYABAAXABgACwACAQA=</trust:BinaryExchange>
</trust:RequestSecurityToken>
</s:Body>

Related

JSON to Specific XML format convertion in Web API

I am going to build a Web API in ASP.Net Core,which Consist of Multiple external Api Calls.
My Api take the request and response as "JSON".But some External Api's only works with XML.Now,I am stuck with converting json to XML in an Api Scenario.More details as follows:
My Api Recieving Request as (Json):
{
"Credential":"mrtest:testpw123,
"BookId": 6,
"BookName": "XXX",
"BookAuthor": "yyy yyy",
"BookPrice":512
}
And I want to Post this same information to an External Api as:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:tns="http://kkr.eu/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<tns:Credential xsi:type="tns:CredentialPro">
<tns:UserName>mrtest</tns:UserName>
<tns:Password>testpw123</tns:Password>
<tns:UserID>4</tns:UserID>
</tns:Credential>
</soap:Header>
<soap:Body>
<tns:AddBookDetails>
<tns:BookId>6</tns:BookId>
<tns:BookName>XXX</tns:BookName>
<tns:BookAuthor>yyy yyy</tns:BookAuthor>
<tns:BookPrice>512</tns:Price>
</tns:AddBookDetails>
</soap:Body>
</soap:Envelope>
So I want to Convert Json to XML in above Format.
Is there Any way to do this Simply?
How I Build "tns:UserName,tns:BookId,.." Like tags from Json??
Also Confused About Namespaces including in XML tags.
As I am beginner on Web API Hope you guys Help me..

WSO2 Http Endpoint Error Handling

I'm currently trying to implement error handling on a http endpoint.
This endpoint is used to POST data via a rest API.
<endpoint name="Test_Post_Endpoint" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" statistics="enable" uri-template="https://{uri.var.host}/api/{uri.var.api}">
<timeout>
<duration>60000</duration>
<responseAction>discard</responseAction>
</timeout>
<markForSuspension>
<errorCodes>500</errorCodes>
<retriesBeforeSuspension>5</retriesBeforeSuspension>
<retryDelay>60000</retryDelay>
</markForSuspension>
</http>
<description>Test API</description>
</endpoint>
My goal is to let the ESB retry to connect to the endpoint every minutes maximum 5 times in case of http error 500 (in the ideal world event if the host is not reachable, in case of network issue...)
It this the correct approach ?
Thanks for helping
Nicolas

Get All Sales Order from Quick Book via QuickBook WebConnector using asp.net

I am using QuicBook Premier Edition UK , I have a company file open inside QuickBook. Build a sample WebService provided in samples and host in IIS. Added that application in WebConnector by using qwc file in samples.
I understood the callback methods required by WebConnector in soap service.
• authenticate
• clientVersion
• closeConnection
• connectionError
• getLastError
• receiveResponseXML
• sendRequestXML
I have tested web service by using WebConnector by using Update Selected button and it gives response 'OK' . But I am still confused how to get started with soap service , samples include 3 Xml request
CustomerQuery,
InvoiceQuery and
BillQuery .
How I test these request and see the response by using service . Can anyone explain the steps required to get me started with my own request of Get all Sales Order.
Thanks
Here is the screenshot
Here is the Last Output.
Version:
2.0.0.1
Message:
OK
Description:
Via closeConnection(): CloseConnection called to application.
Response received from application = OK
Explanation:
After calling authenticate(...), the Web Connector will call the sendRequestXML(...) method.
The sendRequestXML(...) method is essentially the Web Connector's way of saying "Hey, what do you want me to do?"
You should respond with a qbXML request telling QuickBooks/the Web Connector to do something. For example, if you are trying to get sales orders from QuickBooks, you could respond with a SalesOrderQuery qbXML request, something like this:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="8.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesOrderQueryRq requestID="2">
</SalesOrderQueryRq>
</QBXMLMsgsRq>
</QBXML>
The Web Connector will then send that request to QuickBooks, it will be processed, and the Web Connector will then call your receiveResponseXML(...) method.
The receiveResponseXML(...) method is essentially the Web Connector's way of saying "Hey, you told me to do something, I did it, and here's all of the data I got back: ... (big blob of XML from QuickBooks here)".
TLDR:
Return a qbXML request from the sendRequestXML method. A qbXML response will be sent to you in the receiveResponseXML method.
More notes:
Bigger explanation of the Web Connector here: http://www.consolibyte.com/docs/index.php/QuickBooks_Web_Connector_Overview
Lots of qbXML examples here: http://www.consolibyte.com/docs/index.php/Example_qbXML_Requests
Hundreds of pages of documentation in the QuickBooks SDK: https://developer.intuit.com/docs/0250_qb/0020_get_set_up/sdk_downloads

Intercepting encrypted SOAP message with SoapUI

I try to intercept encrypted soap message with SoapUI. The reference site of WS Security with Wildfly 8 and Eclipse IDE is
https://docs.jboss.org/author/display/JBWS/WS-Security#WS-Security-Authenticationandauthorization
WS Security implementation is successful and the response message is encrypted successfully. The main key in WS security is manifest.mf. I add the following lines in manifest.mf file and it works well in Eclipse IDE.
Manifest-Version: 1.0
Dependencies: org.apache.cxf.impl, org.apache.ws.security services
Class-Path:
But in SoapUI application soap message encryption is failed. Me reference site is
http://www.soapui.org/soapui-projects/ws-security.html
http://blog.thilinamb.com/2011/02/invoking-secured-web-service-with.html
The SEI throws the following exception.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>These policy alternatives can not be satisfied:
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}ProtectionToken
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IncludeTimestamp: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SymmetricBinding: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens: The received token does not match the endorsing supporting token requirement
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token: The received token does not match the token inclusion requirement
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not ENCRYPTED
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not SIGNED</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The same exception was thrown in Eclipse IDE when I did not add the Dependancies line in manifest.mf file. Do you think those are related and have the same configuration problem?

Integration Testing of secure Spring Web Service

I am trying to write server side integration tests of my Spring Web Service Endpoint secured using
- Spring WS Security 2.1.2.RELEASE and
- WSS4j 1.6.9.
I am trying to follow Spring documentation http://static.springsource.org/spring-ws/sites/2.0/reference/html/server.html. With the setup that I have got so far, I can send a request payload
<myns:MyRequest xmlns:myns="...">
...
</myns:MyRequest>
using MockWebServiceClient as
mockWebServiceClient.sendRequest(withPayload(requestPayload)).andExpect(clientOrSenderFault());
which the integration test properly maps to the endpoint in the test context and I get a "Could not validate request: No WS-Security header found" error as expected.
Problem: Now the problem here is if I send a request in a SOAP envelope with a security header and body, I would get an endpoint not found exception.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myns="...">
<soapenv:Header>
...
</soapenv:Header>
<soapenv:Body>
<myns:MyRequest>
...
</myns:MyRequest>
</soapenv:Body>
</soapenv:Envelope>
since it will try to find an endpoint around "{http://schemas.xmlsoap.org/soap/envelope/}Envelope".
Is there a way to work around this problem?
The newer version of Spring WS Test which is 2.1 has two methods added in RequestCreaters: RequestCreators.withSoapEnvelope(Source soapEnvelope) and RequestCreators.withSoapEnvelope(Resource soapEnvelope) which allow sending SOAP envelopes for Integration testing. http://forum.springsource.org/showthread.php?135298-Integration-Testing-of-secure-Spring-Web-Service

Resources