how pass parameter usin soap web services in ios app - ios

This is my first application to call soap services. generally i am use php service.please any one help to how to call soap service and how to pass parameter using soap service in ios
.

Giving pythonic way for tax-web page (should be similiar to php only libs will be different):
import suds
from suds.client import Client
client = Client("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
result = client.service.checkVat('GB', '11120021' )
In wsdl file you will always find which parameters you should feed to get back result

Related

Post Https SOAP request for performing an action in application using robot framework

I wrote this robot framework test to post a https request to a webservice. The request body is in xml format and not in Json. I have used request library for this, but i am receiving error when i post using the code listed below.
With postman, i had send the body as raw data and got response as 200 ok, but when i try to do the same in robot framework its throwing error 404.
Please help me on this:
Is requests library relevant for post of https xml data soap request
to a web service?
Can any modification be made to below code for posting a https request
to a web service?
Is there any other library through which we could achieve calling
soap web service?
The Robot Framework Script
***Library***
Library String
Library Collections
Library RequestsLibrary
***Variables***
${user} = username
${passwd} = pwd
&{headers} Content-Type=application/soap+xml or text/xml Authorization=Basic encrypted details
${body_request} = <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://example.com/schemas</a:Action><a:MessageID>msgid</a:MessageID><a:ReplyTo><a:Address>url</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">serviceurl</a:To></s:Header><s:Body xmlns:xsi=body"></s:Body></s:Envelope>
*** Test Cases ***
${auth}= Create List ${user} ${passwd}
Create Session alias=proc url=url headers=${headers} auth=${auth}
Sleep 5
${resp2} Post Request alias=proc uri=url data=${body_request} json=None params=None
headers=${headers} files=None allow_redirects=True timeout=None
Should Be Equal As Strings ${resp2.status_code} 200
Log To Console ${resp2.status_code}
Answers to your question mentioned below,
Is requests library relevant for post of https xml data soap request to a web service? - yes, it can be used. however, there are better ways to achieve the same, see the solution below.
Can any modification be made to below code for posting a https request to a web service? - I think it is nothing to do with https, since 400 is bad request, you need to look at the body.
Is there any other library through which we could achieve calling soap web service? - SudsLibrary.
Although, you can make use of requests module to achieve your solution,
My philosophy when making use of robotframework is "SIMPLY MAKE USE OF EXISTING LIBRARIES" which is already verified. Please do not spend time to solve the problem keeping the thought process of "using a language".
Solution
Please make use of "SudsLibrary" library for SOAP requests, look at Keyword Documentation for your reference.
SudsLibrary is a library for functional testing of SOAP-based web services. SudsLibrary is based on Suds, a dynamic SOAP 1.1 client.
pip install robotframework-sudslibrary3
When you use the above library your code would be something similar to the one seen below,
*** Settings ***
Library SudsLibrary
Library Collections
*** Test Cases ***
Sample Testcase On SOAP
${BASE_URL} Set Variable http://www.someservice.com
${SERVICE} Create Dictionary
... name=someservice
... wsdl=someservice.asmx?WSDL
${PORT} Set variable SERVICE_PORT
${METHOD} Set variable CALLSOMEACTION
Set Binding SOAP-ENV http://www.w3.org/2003/05/soap-envelope
Create Soap Client ${BASE_URL}/${SERVICE.name}/${SERVICE.wsdl}
Set Port ${PORT}
Set Headers Content-Type application/soap+xml
Set Headers Authorization Basic encrypted details
Set Headers Soapaction ${EMPTY}
Set Headers Action "${BASE_URL}/${SERVICE.name}/${METHOD}"
${result} Call Soap Method ${METHOD}

Java SOAP client very slow

I am building a client for a web service. I didn't want to the client downloading the wsdl everytime and got this answer.
But evaluating the source files of WSServiceDelegate,
URL url = wsdl.getSystemId()==null ? null : JAXWSUtils.getEncodedURL(wsdl.getSystemId());
WSDLModel model = parseWSDL(url, wsdl, serviceClass);
service = model.getService(this.serviceName);
if (service == null)
throw new WebServiceException(
ClientMessages.INVALID_SERVICE_NAME(this.serviceName,
buildNameList(model.getServices().keySet())));
// fill in statically known ports
for (WSDLPort port : service.getPorts())
ports.put(port.getName(), new PortInfo(this, port));
I see that it still parses the wsdl to get the service. How can I get around that. I provided the endpoint url using the context.
I need the client to be as fast and as small as possible, adding a huge wsdl in there is worst than downloading the wsdl.
For the operations you are interested in, you can build your own SOAP messages based on the wsdl's Request/Response messages and the xsd. You can use Jaxb tools to convert from XSD to Java classes. You then need to make post calls using Http Clients (like Spring RestTemplate) to post the POST body, soap based, to the endpoint address. This will make your calls faster but you have to code more in order to benefit.

Serving a webpage with Redstone

I am developing a web application with Dart using redstone and polymer
Because Dart allows for server and client side development, I wonder what a good pattern for a web application is (specifically to Dart)
Option 1:
Have a server, say, /bin/server.dart
1.1. get a request there and respond with json
#app.Route("/user/:id", methods: const [app.GET])
getUser(int id) { ... }
have a client, i.e. web/user.html and web/user.dart
2.1 in user.dart make a request to server
2.2 receive json and form a proper user.html
Option 2:
Have a server /bin/server
1.1 get a request there and respond with an html page, similar to
#app.Route("/")
helloWorld() => "Hello, World!";
If in the first case I more or less know (and understand) how to make things work, while i find it really frustrating that I do not take advantage of Dart's server-client code-sharing: I need to encode to and decode back json to get the same data. Is there a way to avoid it?
The second option is much less clear for me: how would I serve a web page in this way? How would I make Polymer do its work?
Answers on the questions in the text and a general explanation of a darty way to develop web apps are very much appreciated.
You can see a Redstone + Polymer application example here: https://github.com/luizmineo/io_2014_contacts_demo
Basically, it works as Option 1: The client and server communicates through a service API, and the data is encoded as JSON. Although, Redstone uses the shelf_static package to serve the client code to the browser as well.
If you prefer, it's also possible to use a server side template engine, such as mustache, to build html pages in the server, although, I think it would be really difficult to integrate that with Polymer.
And finally, you always have to encode the data someway when transferring data between client and server, but this doesn't means they can't share code. They can use the same domain classes, for example. Check out the sample application linked above for more details.
I don't think the option 2 is possible. Polymer depends on dart:html which is not allowed on server side.

Is there a way to browse WSDL endpoints using a browser?

I want to test the results from a WSDL service in a browser like IE9 or FireFox. I know that I can view the WSDL XML, but I want to test the return results of an endpoint called GetEmployeeById that accepts a parameter called Id and returns a class. I am assuming this is all serialized to XML, so a browser would be a good fit for testing this. Is this possible?
In case you are using Visual Studio for .net development, I think something much better than a browser probably would to use:
wcftestclient <url>
which can be called from the command prompt and is part of the tools from visual studio.
The tool will help you to build and receive complex objects and see the results already serialized.
internet explorer let's you make a request with simple string parameters if the WSDL provides enough information.
If you haven't seen it, then probably the WSDL is only for discoverability reasons, probably just points to another service in a different transport protocol, not port 80, if the service is not on port 80 you won't be able to use your browser.
You have another more complex tool called FIDDLER that you can format any kind of http request, as well as receiving any kind of requests, like json for example.
You can use this URL to test WSDL endpoints, send request and see response.

How can I create and process SOAP requests in Delphi without HTTP?

Is there a recommended way / a tutorial which shows how to create and process plain SOAP request with Delphi without THTTPRio, for example, if I want to implement SOAP over JMS, SOAP over AMQP or SOAP over SMTP?
Simplified code examples:
// create a SOAP request (client side)
RequestXML := Service.Add(Arg1, Arg2);
This code would generate the XML with the SOAP message for the 'Add' method invocation with the arguments Arg1 and Arg2.
// process a SOAP request (server side)
ResponseXML := Service.ProcessRequest(RequestXML);
This code would take the SOAP request XML and invoke the method. The result of the method invocation will be wrapped as a SOAP response and is ready to be sent to the client.
Take a peek at the TLinkedRIO class ( http://shenoyatwork.blogspot.com/2004/10/using-tlinkedrio.html ). It creates the SOAP request and writes it to a file. Since TLinkedRIO is used for testing purposes, it also contains code to find a (Delphi) Server that implements the Service and have the server read the request from the file, process it and write a response to another file. The caller (client) then reads from the response file. If you want to use a different transport you won't have to do that part: the response will come from a true Service. However, it's a good example to show how the XML serialization is separate from the transport.
PS: The SOAP serialization basically expects IWebNode for its transport needs. And namely the Execute method of that interface. How/where you send the request stream to and how/where you get the response stream from is up to the transport implementation.

Resources