I am new to SOAP webservices, I was given a folder which consists of WSDL, .xsd files. and asked to consume a end point url. "https://abc-bus-dev.xyz.org/service/admin/Update/v", From the WSDL i am able to create a proxy classes for body part but from envelop to body i dont see anything in the wsdl. When i checked with them they asked to create a custom header. I was not sure how to create customer header with name spaces. Also can you please let me know how to add the header to the body and form the XML and send the request and receive response. Can any one please guide me so i can work accordingly and proceed further. i am really in a bad and tough situation, i am writing the code in vb.net
The soap request look like below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://testing.testing.ws.testing.com/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>Testing</wsse:Username>
<wsse:Password>123456</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<trans:Method1>
<!--Optional:-->
<com:UserinfoId>123456</com:UserinfoId>
<sub:params>
<!--Optional:-->
<name>Testing</name>
<!--Optional:-->
<value>98765-45678</value>
</sub:params>
</trans: Method1 >
Right click on the vb.net project and select add --> service reference. It will generate the classes needed to call the webservice.
Then you call the webservice like this. Replace ServiceReference1 with what you named the service. Replace SoapClient with the name service Client
Dim service = new ServiceReference1.SoapClient
The url you posted is not publicly accessible so I could not add a service reference to it
Related
Im completely new to Salesforce and API's.
Im trying to make a Merge record call using SOAP API . Using Postman for the same .
I have imported the WSDL to my local , Called Login method to get the serverURL and sessionId.
Using these parameters to make subsequent merge calls .
During the login , I have used username and password to authenticate .
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<login xmlns="urn:enterprise.soap.sforce.com">
<username>username</username>
<password>password+auth_token</password>
</login>
</soap:Body>
</soap:Envelope>
and getting the below response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<loginResponse>
<result>
<metadataServerUrl>https://**company_name**--dev.my.salesforce.com/services/Soap/m/54.0/00D0Q0000000QP8</metadataServerUrl>
<passwordExpired>false</passwordExpired>
<sandbox>true</sandbox>
<serverUrl>https://**company_name**--dev.my.salesforce.com/services/Soap/c/54.0/00D0Q0000000QP8/0DF0Q0000004Ct6</serverUrl>
<sessionId>**masked**</sessionId>
<userId>xxx</userId>
<userInfo>
.....
</userInfo>
</result>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>
Later im making the Merge call using the session ID returned from the above .
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com"> xmlns:sobject="urn:sobject.enterprise.soap.sforce.com">
<soap:Header>
<urn:SessionHeader>
<urn:sessionId>**masked**</urn:sessionId>
</urn:SessionHeader>
</soap:Header>
<soap:Body>
<merge xmlns="urn:enterprise.soap.sforce.com">
<request>
<masterRecord xsi:type="sobject:Account" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Id xmlns="urn:sobject.enterprise.soap.sforce.com">0010Q00001abcdefgh</Id>
</masterRecord>
<recordToMergeIds>0010Q00001ijklmnop</recordToMergeIds>
</request>
</merge>
</soap:Body>
</soap:Envelope>
and able to merge the records.
My question is - what should the body be if i donot want to use username and password but use Bearer token.
Can i call the login method without passing username and password?
You might be a victim of XY problem. You can't do it in SOAP API, will REST API be an option?
SOAP API's login call demands username and password (+ optional "security token", extra thing you add to password if you log in from untrusted IP). There are no other ways around it.
REST API has more options for logging in but it'd help if you read up about OAuth2 a bit before diving in. You call login and (similar to SOAP API) get back endpoint to use from now on and access_token. That access_token acts like SOAP APIs session id, you use it in next requests. Most of the time they should be interchangeable, access_token obtained via REST should be good to use in SOAP API calls.
If you already have session id / access token (will look like "00D...!....", first part is org id which you can see in Setup -> Company information for example) - you don't need login call. Call the SOAP API's merge directly and pass that value in <urn:sessionId>.
If you don't have session id, want to log in but without hardcoding username and password in your application... You have LOTS of options. Selecting right method is an art and it depends what are you making. A website, a mobile app? For internal users or community? Will it hold some credentials (for example if it needs sysadmin powers, working in background without human interaction) or will it show users the SF login screen and redirect back to the app? There's even "Internet of Things" stuff for pieces of equipment reporting their status to SF or logging in on device without keyboard (TV, fridge) where you initiate process there and finish on laptop or phone...
If you've never heard about OAuth2 before it's a big topic, "login with Google/Facebook/Twitter/LinkedIn" is just a piece of it. You'll be better off reading some blogs, checking out https://trailhead.salesforce.com/en/content/learn/trails/build-integrations-using-connected-apps or even studying to the Identity and Access Manager certification. Clicking through https://openidconnect.herokuapp.com/ might help too.
There's "username-password flow" which looks almost like SOAP API's login.
There's web server flow and user-agent flow for websites & mobile apps to send user to SF login screen (can be really SF, can be some single sign-on, doesn't matter) and back to the app. So your app doesn't see the password, doesn't see any credentials
There's refresh token option in some of these flows (you logged in once with another method, your app received access_token but also refresh_token. When access expires - app can use refresh_token to silently get back to the system without asking user to log in again. For 60 days for example). So you could still have initial "human authorises connection between the apps" but then it can just work in the background
There's JWT flow which you'll have hard time trying in Postman but there are examples such as this and this. You establish trust between SF and your app by uploading a certificate to Salesforce, marking user as allowed to use this method and then the app sends a special request just with username, no password needed.
Is it possible to create a data source in reporting services to pull data from a https data source?
I have successfully managed to create reports that pull from various http SOAP APIs, but when I try to connect to a https data source I get an error.
The error coming back from the webservice is not very descriptive -
<?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"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>An error has occurred while consuming this service. Read the Detail property for further information.</faultstring><faultactor>GetExceptionPolicy</faultactor><detail>An error has occurred while consuming this service. Please contact your administrator for more information. Error ID: a90b9112-c09b-438d-b58b-4dfb852658ce</detail></soap:Fault></soap:Body></soap:Envelope>
The webservice I'm calling is logging the request that SSRS sent in a database, and it is storing it with a leading "?" -
?<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetBiller xmlns="http://tempuri.org">
<AgentID>1</AgentID>
</GetBiller>
</soap:Body>
</soap:Envelope>
I need to use the same SOAP request to be able to call the same implementation of a method but which is exposed by 2 different service endpoints:
Endpoint A - would be for synchronous access via SOAP
Endpoint B - would be for asynchronous access via JMS
Now what am seeing is that the SOAP request Message which works on the JMS and the SOAP webservice endpoint are structurally different.
I wanted to know whether with ApacheCXF it is possible to call the SOAP or JMS endpoints using the same SOAP request ?
In my case I was able to call both endpoints but the requests used is not the same for each
Below is an example of the SOAP message which works on Asynch Endpoint B but which does not work on Synch Endpoint A .. note that I've obtained the Asynch message by executing a Junit test and intercepted the generate message on ActiveMQ queue:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:create xmlns:ns1="http://service.ws.example/">
<CustomPartyModel>
<ns2:customerModel
xmlns:ns2="http://party.beans.commons.example">
<ns2:person>
<ns2:budgetPlanNumber>131484</ns2:budgetPlanNumber>
<ns2:clientSituationCode
xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance" ns3:nil="true" />
<ns2:employeeReduction>J</ns2:employeeReduction>
<ns2:employeeNumber></ns2:employeeNumber>
<ns2:packageNumber>5</ns2:packageNumber>
<ns2:planIndicator xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance"
ns3:nil="true" />
<ns2:privateRelationNumber
xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance" ns3:nil="true" />
</ns2:person>
</ns2:customerModel>
</CustomPartyModel>
</ns1:create>
</soap:Body>
Here is the SOAP Request which works on Synchronous endpoint but not on the Asynch one .. this request was obtained from creating a request from the WSDL :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.example/" xmlns:par="http://party.beans.commons.example">
<soapenv:Body>
<ser:CustomPartyModel>
<par:customerModel>
<par:person>
<par:budgetPlanNumber>131484</par:budgetPlanNumber>
<par:employeeReduction>J</par:employeeReduction>
<par:employeeNumber></par:employeeNumber>
<par:packageNumber>5</par:packageNumber>
<par:professionCodePartner></par:professionCodePartner>
<par:professionDescriptionPartner></par:professionDescriptionPartner>
</par:person>
</par:customerModel>
</ser:CustomPartyModel>
In both cases am using Aegis for data binding , I did try JAXB as well but with no futher success.
Given that its the same method with same method signature you would expect that the same request could be used in both asynch and synch but this does not seem to be the case .
Anybody has had similar issues or could possibly shed some light in regards to this ?
Note that am using the following dependencies:
cxf-api-2.2.2.jar ,
cxf-common-utilities-2.2.2.jar,
cxf-rt-databinding-aegis-2.2.2.jar,
XmlSchema-1.4.5.jar,
cxf-rt-transports-jms-2.2.2.jar,
spring-jms-2.5.5.jar,
acegi-security-1.0.7.jar
Ok I found the solution basically to be able to send Request through JMS and Synchronous SOAP as Document Literal the following is required to be defined on the interface
#WebService
#SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL,parameterStyle=ParameterStyle.BARE)
public interface ExampleAsyncService {
Without the Document / Literal / Bare configuration JMS will have a tendancy of sending RPC wrapped style request .
According to my documentation 3rd party device connects to address:
https://Enrollment.myweb.com/EnrollmentServer/Register.svc
Header:
POST /EnrollmentServer/Register.svc HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
User-Agent: Windows Phone 8 Enrollment Client
Host: Enrollment.myweb.com
..
<?xml version="1.0"?>
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
...
</s:Envelope>
Some samples of SVC I have seen all have some additional methods that they call, like Service.svc/GetData and calling directly Service.svc I will get the standard response:
You have created a service.
To test this service, you will need to create a client and use it to call the service.
Can anyone point me to the correct documentation or even better - to a simple sample in C# on how to create SVC page that can be accessed directly and that would return some XML text?
You can go for REST Service.
See this: http://beyondrelational.com/blogs/dhananjaykumar/archive/2011/02/01/walkthrough-creating-rest-service-in-wcf-4-0.aspx
Also, can use Web API. http://www.asp.net/web-api
I asked about consuming a WCF service from RPG here and received this response: Scott Klement has a presentation and examples: http://www.scottklement.com/presentations/#HTTPAPI
I used SoapUI to test my service and also to get he soap statement to be used with HTTAPI. The service returnes data in SoapUI but I have been unsuccessful using it in the RPG program. SoapUI returns the following, but it seems only to work within SoapUI - it also doesn't include the path to my service which is
http://ServerName/COE/CustByNameList.svc
If I navigate to http://ServerName/COE/CustByNameList.svc?wdsl, I get the wsdl.
Statement returned in SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:GetCustomerData>
<!--Optional:-->
<tem:CustomerNumber>1688</tem:CustomerNumber>
</tem:GetCustomerData>
</soapenv:Body>
</soapenv:Envelope>
The result looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetCustomerDataResponse xmlns="http://tempuri.org/"><GetCustomerDataResult xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:List xmlns:b="http://schemas.datacontract.org/2004/07/WebOrderEntry.Lists"><b:PartialCSTMS><b:ADR19A>3910 LAKEFIELD DR </b:ADR19A><b:ADR29A>JOHNS CREEK FACILITY </b:ADR29A><b:CITY9A>SUWANEE </b:CITY9A><b:CST_x0023_9A>1688</b:CST_x0023_9A><b:NAME9A>JOHNSON CONTROLS </b:NAME9A><b:PHON9A>770-495-9950 </b:PHON9A><b:STAT9A>GA</b:STAT9A><b:ZIPC9A>30024 </b:ZIPC9A></b:PartialCSTMS></a:List></GetCustomerDataResult></GetCustomerDataResponse></s:Body></s:Envelope>
I keep getting 500 internal server errors. I've tried numerous variations of the SOAP statement based on the examples I have seen, but they date back to 2008. Has anyone been successful with calling a WCF service from RPG?
I asked my Twitter network and #alexeivbaranov responded with the following:
Try to compare request & response from SoapUI and your RPG client using TcpMon. As I understand your SoapUI req works fine but RPG req gets 500, so problem in request. Compare them.
Check your headers. You may be missing the soap action. Here is an example of a request to a WCF service exposed using WsHttp binding with security enabled. wsa:Action is the thing you might need.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://somenamespace">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://someuri/Get</wsa:Action>
<wsa:To>http://localhost/someapp/SomeService.svc</wsa:To>
</soapenv:Header>
<soapenv:Body>
<ns:GetRequest>
<ns:Body>
<ns:Id>12345</ns:Id>
</ns:Body>
</ns:GetRequest>
</soapenv:Body>
</soapenv:Envelope>
I had to throw the towel in on using HTTPAPI to consume my WCF web service - just could not get past HTTP 400 and 500 errors. Logging wasn't helping. I believe I finally managed to get the SOAP call correct but then started receiving errors that seemed to translate into special character issues.
Instead, I ended up using IBM's IWS and got it working. These two links were of great help:
http://www.ibm.com/developerworks/ibmi/library/i-amrawsdl2rpg/index.html
http://www.iprodeveloper.com/article/rpg-programming/consume-web-services-with-ibms-iws-66209