When attempting to perform an HTTP post via Swagger (using the Swagger Type Provider) I get a 401 Unauthorized.
I suspect the answer to this might be UseDefaultCredentials which isn't exposed when inheriting from the SwaggerProvider.Internal.ProvidedSwaggerBaseType. So I was thinking that an upcast :> might help but posts I've seen elsewhere indicate naïveté.
Also, updating the config for fsi.exe to include the following proved wishful:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy usesystemdefault="True" />
</defaultProxy>
</system.net>
Might anyone have a simple answer?
Thanks
Schema access
SwaggerProvider assumes that Swagger schema is easy-accessible and can be downloaded using simple Http request without authentication
type PetStore = SwaggerProvider<"http://petstore.swagger.io/v2/swagger.json">
user also can add any HTTP header to schema-request like this
type PetStore = SwaggerProvider<"http://petstore.swagger.io/v2/swagger.json", "Content-Type=application/json">
It can be Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l header, but this literal string will be hard-coded in source code.
If schema-request requires more complex authentication, will be easier to download it and put it near source code
[<Literal>]
let schemaPath = __SOURCE_DIRECTORY__ + "/PetStore.Swagger.json"
type PetStore = SwaggerProvider<schemaPath>
Requests control
When schema are in place you have a full control over all HTTP request to the server using CustomizeHttpRequest parameter in provided type.
For example, if you want to use default credentials:
let store =
PetStore(
CustomizeHttpRequest=
fun (req:System.Net.HttpWebRequest) ->
req.UseDefaultCredentials <- true
req)
You are free to modify web request as you need:
Use default credentials
Specify runtime Credentials
Add headers to HTTP request
Add cookies to HTTP request
Break request ;) and etc.
CustomizeHttpRequest will be called in the run-time for each request, after SwaggerProvider built it and before call to the server. So you can change anything you want.
I am requesting OData service like this,
https://www.example.com/part1/part2/_vti_bin/myServiceFolder/MyOdataService.svc
but when it returns xml back...
I am getting this,
"<?xml version="1.0" encoding="utf-8"?><feed
xml:base=https://www.example.com/_vti_bin/myServiceFolder/MyOdataService.svc
What could had caused it ? I am hosting this service in SharePoint web application.
Found answer here,
https://blogs.msdn.microsoft.com/peter_qian/2010/03/23/overwriting-the-service-root-uri-in-wcf-data-service/
Basically it was using host's name or url and constructing response, so I had to overwrite following according to my needs,
OperationContext.Current.IncomingMessageProperties["MicrosoftDataServicesRootUri"] = serviceUri;
OperationContext.Current.IncomingMessageProperties["MicrosoftDataServicesRequestUri"] = requestUri;
I am connecting to SFDC with mule connector by oauth, trying to authorize but getting following error message.
<flow name="sfdcFlow1" doc:name="sfdcFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="sfdc" doc:name="HTTP"/>
<sfdc:authorize config-ref="Salesforce__OAuth_v2_0" display="POPUP"
accessTokenUrl="https://na1.salesforce.com/services/oauth2/token"
authorizationUrl="https://na1.salesforce.com/services/oauth2/authorize"
doc:name="Salesforce"/>
</flow>
getting following error message in the browser:
error:redirect_uri_mismatch&error_description=redirect_uri must match configuration
what is redirect or callback url? Do I need to have another flow and http requests?
I made this but didnot work:
<http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="callback" doc:name="HTTP"/>
<logger message="===callback====" level="INFO" doc:name="Logger"/>
</flow>
Edit:
I have an url from sfdc as: https://cs17.salesforce.com/. IS this is the url to be used for redirect?
Mules ref docs says to use
oauthcallback as path. I am using Anypoint studio with sfdc connector 6.0.1. Even after using same error message I receive it.
<sfdc:oauth-callback-config domain="localhost" localPort="8081" path="oauthcallback"/>
Mulesoft ref docs
Reference -1
Callback URL is where Salesforce will redirect after successful authentication. I have not used it with Salesforce but I have done this with other cloud connector and you can refer some of my slide share for details. Please try with those links and let me know if u still have any issue.
http://www.slideshare.net/rupeshkrsinha/integration-with-dropbox-using-mule-esb
http://www.slideshare.net/rupeshkrsinha/integrating-with-linkedin-using-mule-esb-linkedin-connector
Trying to call a SAP SOAP Web Service from a generated sudzc app shows errors I don't know:
SudzCExamples[5192:f803] <?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/" xmlns="urn:sap-
com:document:sap:soap:functions:mc-style"><soap:Body><ZComUrlGetrecords>
<IYear>2012</IYear></ZComUrlGetrecords></soap:Body></soap:Envelope>
SudzCExamples[5192:f803] <soap-env:Envelope xmlns:soap-
env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header></soap-env:Header><soap-
env:Body><soap-env:Fault><faultcode>soap-env:Server</faultcode><faultstring
xml:lang="en">CX_ST_MATCH_ELEMENT:XSLT exception.System expected element
'IYear'</faultstring><detail><ns:SystemFault
xmlns:ns="http://www.sap.com/webas/710/soap/runtime/abap/fault/system/">
<Host>undefined</Host><Component>APPL</Component><ChainedException>
<Exception_Name>CX_SOAP_CORE</Exception_Name><Exception_Text>CX_ST_MATCH_ELEMENT:XSLT
exception.System expected element 'IYear'</Exception_Text></ChainedException>
<ChainedException><Exception_Name>CX_SXMLP</Exception_Name><Exception_Text>XSLT
exception</Exception_Text></ChainedException><ChainedException>
<Exception_Name>CX_ST_MATCH_ELEMENT</Exception_Name><Exception_Text>System expected
element 'IYear': Main Program:/1BCDWB/WSS825E06E4DEC40F9171D|
Program:/1BCDWB/WSS825E06E4DEC40F9171D| Line: 18| Valid:X</Exception_Text>
</ChainedException></ns:SystemFault></detail></soap-env:Fault></soap-env:Body></soap-
env:Envelope>
2012-03-11 20:09:30.631 SudzCExamples[5192:f803] soap-env:Server CX_ST_MATCH_ELEMENT:XSLT
exception.System expected element 'IYear'
(null)
The strange thing is that it seems as if the request has the IYear element. Can someone tell me where to search the problem?
I ran into this same problem yesterday and discovered the solution after some experimentation. First thing I did was use my SoapUI client to make the request successfully. SoapUI comes with a free trial and even if you do not use the free trial you can still use it to make accesses to the web service without registering it. I used the xml from the successful request I made to compare against the request that SudzC was making. They differ in several ways, and the way that SudzC forms the request is not sufficient.
My suggestion to you is to compare the two requests and change SudzC's request to match the SoapUI request. You can do this by editing the Soap source code that SudzC gives to you, this source code is found particularly in the Soap.m file in the createEnvelope function.
Also, if your requests have an empty header SudzC does not include the header part of the request. Hard code in an empty header after the namespace portion of the envelope. Doing all this fixed this exact issue for me.
I have been struggling with the following error the last couple of
days can you please help!
I generated my server and client code using the wsdl2java tool from a
wsdl 2.0 file.
When invoking the webservice I am getting the following error:
org.apache.axis2.AxisFault: The endpoint reference (EPR) for the
Operation not found is
/axis2/services/MyService/authentication/?username=Denise345&password=xxxxx
and the WSA Action = null
My service is displayed on the axis2 webpage with all available methods.
Here is the output from TcpMon
==============
Listen Port: 8090
Target Host: 127.0.0.1
Target Port: 8080
==== Request ====
GET /axis2/services/MyService/authentication/?username=Denise345&password=xxxxx
HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
SOAPAction: ""
User-Agent: Axis2
Host: 127.0.0.1:8090
==== Response ====
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: application/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 12 May 2011 15:53:20 GMT
Connection: close
12b
<soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Text xml:lang="en-US">The endpoint reference (EPR) for the
Operation not found is
/axis2/services/MyService/authentication/?username=Denise345&password=xxxxx
and the WSA Action = null</soapenv:Text></soapenv:Reason>
0
==============
I am using:
axis2-1.5.4
Tomcat 7.0.8
wsdl 2.0 file
Please help!
In my case it was caused by a wrong Content-Type in the HTTP POST. Setting it to text/xml solved the problem.
Try adding ?wsdl to the string.
As described by Eran Chinthaka at http://wso2.com/library/176/
If Axis2 engine cannot find a service and an operation for a message,
it immediately fails, sending a fault to the sender. If service not
found - "Service Not found EPR is " If
service found but not an operation- "Operation Not found EPR is and WSA Action = "
In your case the service is found but the operation not. The Axis2 engine uses SOAPAction in order to figure out the requested operation and, in your example, the SOAPAction is missing, therefore I would try to define the SOAPAction header
It happens because the source WSDL in each operation has not defined the SOAPAction value.
e.g.
<soap12:operation soapAction="" style="document"/>
His is important for axis server.
If you have created the service on netbeans or another, don't forget to set the value action on the tag #WebMethod
e.g. #WebMethod(action = "hello", operationName = "hello")
This will create the SOAPAction value by itself.
Action is null means that no Action in given SOAP Message (Request XML). You must set Action before SOAP call:
java.net.URL endpoint = new URL("<URL>"); //sets URL
MimeHeaders headers = message.getMimeHeaders(); // getting MIME Header
headers.addHeader("SOAPAction", "<SOAP Action>"); //add Action To Header
SOAPMessage response = soapConnection.call(<SOAPMessage>, endpoint); //then Call
soapConnection.close(); // then Close the connection
I had this same problem using curl to send a soap request. Solved it by adding "content-type: text/xml" to the http header.
I hope this helps someone.
This error is coming because while calling the service, it is not getting the WSDL file of your service.
Just check whether WSDL file of your service is there--> run server and from browser run axis 2 apps on local host and check the deployed services and click on your service, then it shows WSDL file of your service.....or check the service path in your client file.
I hope it may help you to resolve the problem.
This can be solved by disabling validation
<proxy>
<!-- . . . -->
<parameter name="disableOperationValidation">true</parameter>
</proxy>
Late answer but:
I see you do a GET - should be a POST ?
try removing the extra '/' after the operation name (authentication) when invoking through the client
/axis2/services/MyService/authentication?username=Denise345&password=xxxxx
It seems don't find wsdl file..
I've solved adding wsdlLocation parameter at javax.jws.WebService annotation
By removing cache wsdl-* files in /tmp folder, my problem was solved
see https://www.drupal.org/node/1132926#comment-6283348
be careful about permission to delete
I'm in ubuntu os
On Websphere Application Server, in the same situation, it helped deleting the Temp folders while the server was stopped.
I ran into the situation when the package of the service changed.
Open WSDL file and find:
<soap:operation soapAction="[actionNameIsHere]" style="document"/>
Add to the requests header [request send to service]:
'soapAction' : '[actionNameIsHere]'
This work for me.
For devs. using node-soap [ https://github.com/vpulim/node-soap ] - example:
var soap = require('soap');
var options = {
...your options...
forceSoap12Headers: true
}
soap.createClient(
wsdl, options,
function(err, client) {
if(err) {
return callBack(err, result);
}
client.addHttpHeader('soapAction', '[actionNameIsHere]');
...your code - request send...
});
I got this error because the SOAP request I was sending to the server was malformed and had an empty Body
In this case the error message from the server is misleading and can be solved changing the request content, without changing anything about operations, URLs, WSDL, etc