How can I add WSSE Header to my Web Service Client? - web-services

I want to add wsse Security header to my web service client on ASP 3.5. I test the web service from SoapUI using this Soap Envelope and get an answer:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:comp="http://myCompany.org.tr"> <soapenv:Header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
<wsse:Username>MyUsername</wsse:Username>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
(Body Info.)
</soapenv:Body>
</soapenv:Envelope>
I want to create this envelope through classic Web Service Reference which created by Visual Studi 2012. Which class should I use to add Username Info to my envelope?

Thank you John, and Ladislav.
Turns out that you should add the header via web.config file to get properly ordered SOAP message. Otherwise .Net tries to nest your code with its own capsulation (even you dont ask for it), and sends some rubbish as a result.

Related

Cannot consume Talend Soap API

I am trying to use the Tsoap component within Talend to consume the API. I have tried the Soap UI Client (separate application) and was able to get the response.
However within the Tsoap component within the Soap Message, I have pasted the sample request and I get an error eery single time. Can anyone help!
" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns=\"http://clients.mindbodyonline.com/api/0_5\">
<soapenv:Header/>
<soapenv:Body>
<GetSites>
<Request>
<SourceCredentials>
<SourceName>Test235</SourceName>
<Password>3IERKOFDNFEOFMKDFOEMFD=</Password>
<SiteIDs>
<int>-99</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Full</XMLDetail>
<PageSize>0</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
</Request>
</GetSites>
</soapenv:Body>
</soapenv:Envelope>"
What am I doing wrong?? Can anyone help please.
Can you send the error what you are getting?
Try this if you haven't done (just a guess)
--> If you are using and HTTPS web service then make sure to setup the authentication( I used Trust serve with SLL and provided the keystore file path and password)

Creating application with permissions using webservice API

I'm trying to create a serviceProvider including permissions using the webservice API of WSO2IS 5.1.0
The API I'm using is the one you can find on https://docs.wso2.com/display/IS510/Identity+Application+Management+API
Simply creating a serviceProvider with the request below works fine.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://model.common.application.identity.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<xsd:createApplication>
<xsd:serviceProvider>
<xsd1:applicationName>APP_NAME</xsd1:applicationName>
<xsd1:description>My application name</xsd1:description>
</xsd:serviceProvider>
</xsd:createApplication>
Trying to create a serviceProvider with permissions with the request below fails with the message
Error while storing permissions for application APP_NAME
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://model.common.application.identity.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<xsd:createApplication>
<xsd:serviceProvider>
<xsd1:applicationName>APP_NAME</xsd1:applicationName>
<xsd1:description>My application name</xsd1:description>
<xsd1:permissionAndRoleConfig>
<xsd1:permissions>
<xsd1:value>permission1</xsd1:value>
</xsd1:permissions>
</xsd1:permissionAndRoleConfig>
</xsd:serviceProvider>
</xsd:createApplication>
I cannot find any further information in the logs and also the example request messages on the WSO2 documentation site are lacking any information.
Any help or suggestion is welcome

WSO2 ESB requirement to pass xml as a Soap Attachment

We have a requirement to pass xml as a Soap Attachment in soap request. At present we are handling this requirement in a custom class mediator; we are trying to achieve this requirement through WSO2 ESB inbuilt mediators without coding the functionality in a custom class mediator. We are exploring for this option on WSO2 ESB 4.9.0 and 4.8.0
Please provide your valuable suggestions.
Soap request with attachment is as shown below. Xml file is attached is passed in the custom class mediator.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:swa="http://aasws.com/swa">
<soapenv:Header>
<swa:OurHeader>
<swa:Credential>
<swa:Username>XXXX</swa:Username>
<swa:Password>XXXX</swa:Password>
<swa:Dbtitle>XXXX</swa:Dbtitle>
<!--Optional:-->
<swa:Domain/>
<!--Optional:-->
<swa:Accessuser/>
</swa:Credential>
</swa:OurHeader>
</soapenv:Header>
<soapenv:Body>
<swa:getServiceInfo>
<swa:attachmentID>XXXX.xml</swa:attachmentID>
</swa:getServiceInfo>
</soapenv:Body>
</soapenv:Envelope>
You can send a SOAP attachment in WSO2 ESB via MTOM. Please find the following links which explain in detail how you can achieve this task.
[1] http://hi-my-world.blogspot.com/2015/01/sending-attachements-with-with-esb-via.html
[2] https://docs.wso2.com/pages/viewpage.action?pageId=33136025
[3] http://wso2.com/library/1148/
Cheers,
Pubudu.

Unable to invoke WSO2 API Manager 1.10 admin services

I have enabled the admin services from carbon.xml for API Manager and extracted the wsdl successfully. Now I am trying to invoke the service RemoteTenantManagerService using SOAP UI. I have loaded the wsdl in SOAP UI and also provided the Basic authentication Username/Password as admin/admin. But I am getting following message back. Port for API Manager is Offset 1
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.um.carbon.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<ser:getAllTenants/>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>The service cannot be found for the endpoint reference (EPR) /services/RemoteTenantManagerService.RemoteTenantManagerServiceHttpsSoap11Endpoint</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
There are two types of transports, PassThrough and servlet. The admin services are exposed through servlet transport. Hence those must be invoked using servlet transport port.
For ex:- https://{host}:9443/services/RemoteTenantManagerService
In your case you have set offset to the "1" so please call the service using the URL https://{host}:9444/services/RemoteTenantManagerService
The generated WSDL contains the endpoint with Passthrough port hence soapUI shows it as the default endpoint. Please change the port to servlet port (your case it should be 9444) and run again.

Error in WSO2 ESB when calling service without Header element

I believe I found bug in WSO2 ESB.
I defined proxy service for our customer.
With security turned off I always get expected result, but when I enable security (scenario 1 - UsernameToken), then I get error "SOAP Envelope can not have children other than SOAP Header and Body".
I'm able to reproduce this bug with 'echo' service.
Here is request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:echo="http://echo.services.core.carbon.wso2.org">
<soap:Body>
<echo:echoString>
<in>ABC</in>
</echo:echoString>
</soap:Body>
</soap:Envelope>
Turning security off or adding <soap:Header /> element before <soap:Body> element provides expected response again.
I'm using WSO2 ESB version 4.8.1, SoapUI 5.0.0 as client.
The SOAP headers contain application specific information related to the SOAP message. They typically contain routing information, authentication information, transaction semantics etc.
If you removed <soapenv:Header/> SoapUI will not send your user name and password to rampart.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<echo:echoString>
<!--Optional:-->
<in>ABC</in>
</echo:echoString>
</soapenv:Body>
</soapenv:Envelope>
So your error was return by org.apache.axiom.soap.SOAPProcessingException due to AxisEngine System error.
When your sending request to secured one header is must..