I am going to develop a C# application using web service but the service is developed by Apache Axis2 and I can not handle the service to integrate adding service reference in C#. I get no response and only format exception.
I don't have service code, it's like ready-to-use web service, just give service reference and get started to use it.
The web service wsdl address is:
https://pttws.ptt.gov.tr/PttBilgi/services/Sorgu?wsdl
I also tried to run the service with SOAP UI but the XML response I get is like below:
<faultstring>The endpoint reference (EPR) for the Operation not found is /PttBilgi/services/Sorgu.SorguHttpSoap11Endpoint/ and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.</faultstring>
The raw response is like below, too which is but with some technical detail:
HTTP/1.1 500 Internal Server Error
Date: Fri, 14 Apr 2017 07:20:28 GMT
Server: gizli gizli gizli gizli
X-OPNET-Transaction-Trace: a2_5cc44d1b-0e0c-48a5-a44f-942377e9ab70
X-Powered-By: Servlet/2.5 JSP/2.1
Vary: Accept-Encoding,User-Agent
Connection: close
Transfer-Encoding: chunked
Content-Type: application/xml; charset=UTF-8
<faultstring>The endpoint reference (EPR) for the Operation not found is /PttBilgi/services/Sorgu.SorguHttpSoap11Endpoint/ and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.</faultstring>
It seems that content type has to be text/html to use it in C# apps but being of the service's content type is application/xml, so it can not convert to read and process the result.
How can I use the service with success, what do I have to do?
Thanks guys!
As described in this article 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 = "
Related
I am working on a Chatbot in Slack that sends a POST request to http://localhost:44331/values/api an .NET Core API that i built in C#. In the Post request is a response_url in the body I can use to send back the needed information.
So I have been trying to make this work for about two weeks now and used a fiddler and to mimic the request so I can make some changes on the body and the headers to see if that makes a difference.
So after a lot of errors I have come to two specific errors that haven't changed for a long while.
sent with the Slack Chatbot: curl_error_56
There really isnt much I can change in this matter except the url I want to send the request to.
In fact this request has never even reached the post method in my API.
Thats what the Slackbot answers
sent with fiddler: HTTP error 400
I used Requestbin to get the information that has been sent by the bot and copied it into the composer in fiddler.
I am a total novice to Web programming in any kind of way so I really don't know what they have in common.
Are those errors coming because I am using localhost?
What am I missing?
here is the request so you can copy it if needed
host: localhost:44331
Accept: application/json,*/*
Accept-Encoding: gzip,deflate
Content-Type: application/x-www-form-urlencoded
User-Agent: Slackbot 1.0 (+https://api.slack.com/robots)
X-Slack-Request-Timestamp: 1569238196
X-Slack-Signature: v0=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Length: 381
Connection: keep-alive
Alright I got some help by a friend and he explained to me that Slack is unable to access my localhost, because it is not a local app. It is taking its information from the web and making it send a request to my localhost is useless because it is not a static IP.
What i need is an Endpoint.
I can get one by requesting it from my ISP (Internet Service Provider) or getting myself a server which already has an static IP.
Thanks for any help you wanted to provide.
I create a web services and a ConsoleApplication to consume it. I am using fiddler to see the traffic, i was hoping that the request and response was SOAP but that's don't happend, only the request was SOAP, not the response.
How can i force to my service that respond using soap?
This is the raw http header obtained:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 17 Nov 2014 20:19:22 GMT
Content-Length: 311
The respond is in binary.
My web-service was created adding a Web Services item to ASP.NET Empty Web Application project, and i don't modified, later I published in IIS.
My consumer is very simple too. I just add the service reference and create an instance.
var binding = new BasicHttpBinding();
var endpointAddress = new EndpointAddress("http://172.20.48.59/web-services/MyWebService.asmx");
var serviceRefWithoutConfig = new ServiceReference1.MyWebServiceSoapClient(binding, endpointAddress);
Console.WriteLine(serviceRefWithoutConfig.HelloWorld());
The HTTP response in question is compressed with GZIP.
What happens after you click the big yellow bar in Fiddler that says Response is encoded and may require decoding before inspection. Click here to transform.?
If you are creating something new, I strongly suggest you look at using WebAPI for something like this.
It's much easier to control the output of your methods, and the resulting service will be easier to consume from mobile platforms, should the need arise in future.
I'm hosting a magento webshop on my local machine using IIS 7.5 and PHP 5.6 (testing). The shop is working just fine, but now I want to create a separate application using visual studio 2013. These are the steps that I've taken:
I've added the domain name "www.domain.com.local" to my hosts file directing to my localhost (www.domain.com.local -> 127.0.0.1)
I've created a new website on my IIS and added a new binding (www.domain.com.local - see 1)
I've added WinCache extension with the PHP Manager and set the PHP version to 5.6
Enable WS-I Compliance in the magento backend (System > Configuration > Magento Core Api)
Create a SOAP Role and User (Resource Access = All)
Open visual studio 2013 and create a new Console Application
Adding a new Service Reference (http://www.domain.com.local/index.php/api/v2_soap/?wsdl)
Trying to login - This is not working like it should be
Here is my piece of code:
class Program
{
static void Main(string[] args)
{
MainAsync(args).Wait();
}
static async Task MainAsync(string[] args)
{
using (var proxy = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient())
{
try
{
var loginResponse = await proxy.loginAsync("soap-admin", "xxxxxxxxx"); // api key
var sessionId = loginResponse.result;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}
And this is the error I'm getting:
The content type text/xml; charset=utf-8,text/xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 297 bytes of the response were: '<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:loginResponseParam>
<result>13fa067676759c3ce8ddd61c386b6d5c</result>
</ns1:loginResponseParam>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'.
So as you can see, I'm getting my sessionId but keep getting this error. I've also used fiddler to investigate and getting a correct response: HTTP 200 OK. Does someone knows what the problem could be? Is it IIS related? localhost related?
(When I add the url as web reference it works just fine - old webservice method).
Related topics I've read and tried (without success):
C# SOAP - Error in deserializing body of reply message (Magento API)
C#+Magento API V2:The content type text/xml; charset=utf-8,text/xml; charset=UTF-8 of the response message does not match
If got this answer from Rian at Magento Stack Exchange. All credits go to Rian
The solution:
The problem you're experiencing is that .NET/C# is having trouble parsing the content type Magento is sending along with it's response. SOAP is notoriously finicky about receiving just the right stuff in just the right format. Couple that with PHP's rather poor implementation of the protocol and you're in for a lot of fun.
I'm looking at a Magento 1.9 for the following information:
After some digging I found that the header for the SOAP calls are set in app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php on line 52.
51. ->clearHeaders()
52. ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset)
53. ->setBod...
Note that that Content-Type header matches your text/xml; charset=utf-8 desired charset. Adjusting line 52 to:
52. ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset, true)
tells Magento to force overwriting that header if it's already set.
Make sure to make a copy of the file with it's full path to the app/code/local/Mage/... to avoid overwriting core files. You'll thank me when you want to upgrade Magento at some point.
Also, make sure to look carefully, there's two setHeader() calls in that file.
And finally, there's also a WS-I compliant SOAP adapter available, the same fix applies to that file. You can find it in app/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php.
I was hoping one of you could help me with the use of AWS Kinesis. I have been pouring over the documentation and I am still unable to post a "blob" of data to a Kinesis stream.
In the API the standard POST request is as follows.
POST / HTTP/1.1
Host: kinesis.<region>.<domain>
x-amz-Date: <Date>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=contenttype;
date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid, Signature=<Signature>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive
X-Amz-Target: Kinesis_20131202.PutRecord
{
"StreamName": "exampleStreamName",
"Data": "XzxkYXRhPl8x",
"PartitionKey": "partitionKey"
}
Using "Postman" a google chrome app to make Http requests and filling in the appropriate information for the above fields I cannot for the life of me figure out how to make a successful data post to a stream. I was unable to do this successfully so i went on to do use the .NET SDK for visual studio.
I made a quick command line c# console application I am still having some issues.
My code:
http://pastebin.com/cyJeC0vU
The error message, System.Xml.XmlException was unhandled, appears on line 61 of the code: http://pastebin.com/HEG7DmMw
Has anyone had a successful experience using AWS Kinesis. I would love to pick your brain / repay you somehow for a bit of tutoring.
Thanks again for all of your help!
The error you're getting indicates that the response from the service was not able to be parsed. There is a clue in that the SDK switched from the JSON parser to the XML parser because the response looked like XML. This usually indicates that you are behind a proxy which requires authentication, and the proxy is giving you an HTML error message.
You can verify this by firing up a protocol analyzer like Fiddler and watching the request traffic. If your proxy requires credentials, here is some documentation about using the AWS SDK for .NET with proxies:
Configuring Credentials for Your AWS SDK for .NET Application
Note: This question was originally part of Magento SOAP API V2 with C#: Issue with Stores that Require HTTP Authentication but I have moved a part of it here as a new question, as one part was already answered on that post.
ISSUE:
I have built a tool to import sales orders from customer stores (magento) for integration into our legacy order processing system. I have five stores to import from. Three work fine. Two of them have the following problem:
The following Exception is thrown upon executing the salesOrderList() call:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
There is an error in XML document (2, 372).
The login succeeds, I am able to enumerate attribute values, etc.
But I am unable to run the salesOrderList() function with any
filter (and null too). It would be great if someone has experience
with this and can point me in the right direction, please.
Update: The invoking call is as follows:
salesOrderEntity[] soe = mservice.salesOrderList(mlogin, objSalesOrderFilterSet);
The Exception is, There is an error in XML document (2, 372).
The InnerException is, The specified type was not recognized: name='salesOrderListEntity', namespace='urn:Magento', at .
Fiddler showed the following requested and returned for the salesOrderList() call:
Requested:
POST /api/v2_soap/index HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.239)
VsDebuggerCausalityData: uIDPoz6RG9JzwkdBniF95/gqmAcAAAAAhgJHnbvB1UOTE1y4R1Iq5VGLcSLUxTNDg57BO/4OizgACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction"
Host: www.contoso.com
Content-Length: 1753
Expect: 100-continue
Returned:
POST http://www.contoso.com/api/v2_soap/index HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.239)
VsDebuggerCausalityData: uIDPoz6RG9JzwkdBniF95/gqmAcAAAAAhgJHnbvB1UOTE1y4R1Iq5VGLcSLUxTNDg57BO/4OizgACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction"
Host: www.contoso.com
Content-Length: 1753
Expect: 100-continue
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:Magento" xmlns:types="urn:Magento/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><tns:salesOrderList><sessionId xsi:type="xsd:string">2f9c5bdc898fd92c1f61981147ee5495</sessionId><filters href="#id1" /></tns:salesOrderList><tns:filters id="id1" xsi:type="tns:filters"><complex_filter href="#id2" /></tns:filters><soapenc:Array id="id2" soapenc:arrayType="tns:complexFilter[3]"><Item href="#id3" /><Item href="#id4" /><Item href="#id5" /></soapenc:Array><tns:complexFilter id="id3" xsi:type="tns:complexFilter"><key xsi:type="xsd:string">created_at</key><value href="#id6" /></tns:complexFilter><tns:complexFilter id="id4" xsi:type="tns:complexFilter"><key xsi:type="xsd:string">created_at</key><value href="#id7" /></tns:complexFilter><tns:complexFilter id="id5" xsi:type="tns:complexFilter"><key xsi:type="xsd:string">status</key><value href="#id8" /></tns:complexFilter><tns:associativeEntity id="id6" xsi:type="tns:associativeEntity"><key xsi:type="xsd:string">from</key><value xsi:type="xsd:string">2011-12-28 00:00:00</value></tns:associativeEntity><tns:associativeEntity id="id7" xsi:type="tns:associativeEntity"><key xsi:type="xsd:string">to</key><value xsi:type="xsd:string">2011-12-28 23:59:59</value></tns:associativeEntity><tns:associativeEntity id="id8" xsi:type="tns:associativeEntity"><key xsi:type="xsd:string">in</key><value xsi:type="xsd:string">processing</value></tns:associativeEntity></soap:Body></soap:Envelope>
HTTP/1.1 200 OK
Date: Thu, 05 Jan 2012 12:11:19 GMT
Server: Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/1.0.0-fips mod_bwlimited/1.4 mod_fcgid/2.3.6
X-Powered-By: PHP/5.3.6
Content-Length: 6302
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:salesOrderListResponse><result SOAP-ENC:arrayType="ns1:salesOrderListEntity[1]" xsi:type="ns1:salesOrderListEntityArray"><item xsi:type="ns1:salesOrderListEntity"><increment_id xsi:type="xsd:string">100001306</increment_id><store_id
...<more data>...
xsi:type="xsd:string">John</firstname><lastname xsi:type="xsd:string">Doe</lastname><telephone xsi:type="xsd:string">999-999-9999 ext. 3333</telephone><postcode xsi:type="xsd:string">11111</postcode></item></result></ns1:salesOrderListResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
This has an easy fix, though it might take some time and you need to change some code.
The problem: You can't use the Magento WSDL address if not less than 1.6.0, as it contains weird bugs that are fixed only with 1.6, read the release notes of each version for more information
The Solution: Remove all Service References from your project and create a proxy using the svcutil.exe utility pointing to a wsdl address that is from the most recent Magento (even if you install the latest version just for this, the latest stable to this date is 1.6.1).
Then add that generated project to your web/win project and use the service from it, and swap the final url in the Client object, for example:
MyNameSpace.MagentoSoapClient ws = new MyNameSpace.MagentoSoapClient();
ws.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://domain.com/api/v2_soap");
give that a try.
OKay, here goes. The service reference in the original program was created by pointing to a wsdl address under one of our Magento Go stores. The program allowed dynamically changing the shop to work with, and so the URL was changed to the relevant shop URL appended with /api/v2_soap/index at runtime.
As explained in the question, the sales order import worked for some sites and failed for others. After some pretty good advice by balexandre, we used fiddler and some on-the-spot code as needed and figured out the issue.
The Problem Was: The service call salesOrderList() returns salesOrderEntity[] for Magento Go shops and salesOrderListEntity[] for 1.5.x shops. As the proxy was created using a Magento Go reference, the latter type was "unexpected" for the program, thereby causing the Exception There is an error in XML document (2, 372) with the innerException The specified type was not recognized: name='salesOrderListEntity', namespace='urn:Magento'. All the other methods that we had invoked from the web service worked though. But without sales order listing, they weren't much useful on their own.
An Intermediate Workaround Was: To tweak the wsdl file and reference.cs to declare 'salesOrderListEntityand to create an overloaded version ofsalesOrderListEntity()`. But this workaround created more problems than it solved.
The Final Solution Is: Create two different proxies by pointing to Magento Go and Magento 1.5.x. After switching to the actual shop URLs at runtime, use the proxy relevant for the current shop. Same calls and flow, except that the first proxy knows that it will receive salesOrderEntity[] for a salesOrderList() call and the second proxy knows that it will receive salesOrderListEntity[].
This works without issues and we have imported a few hundred sales orders as I write this. And it seems to work well for 1.6.1 shops as well. But I shall let you know if (God forbid) there be any issues on that front.
On a concluding note, my sincere thanks to balexandre for all the help extended.