Is there a way to intercept RPC calls to UNIMPLEMENTED RPC - grpc

I made a change to the .proto file where the path of a method changed
old .proto
package foo
rpc test
Method path is foo.test
new .proto
package foo.v1
rpc test
Method path is foo.v1.test
Of course, old clients will stop working with error
12 UNIMPLEMENTED: unknown service foo.test
I don't want to version my APIs instead I want to run a server interceptor that fixes the path for each incoming request.
The issue is the client gets an error response UNIMPLEMENTED before the request is handled by the interceptor.
To my understanding, the interceptor function is executed before the handler but, it seems there is code running that check the connection and the method name before the interceptor.
My question is how to get the server interceptor to run first and change the method path?
Ps. the cleint uses grpc-js

The method path can't be changed after call method. The interceptor execute later than find method by service and method name. So you should not remove the origin method when any client still call this method.

Related

How to pass an Object from a Servlet to JSR-356 WebSocket

I have a JSP-type servlet that registers a WebSocket Endpoint with the Servlet container.
I want to pass a reference of that servlet, and/or some of its objects, to the WebSocket Endpoint, so that I can use the code from that servlet, e.g. for Authentication or Session management (the servlet has its own non-Java EE Session management).
I was hoping that I could set some attribute somewhere when I call addEndpoint() on ServerContainer, because at that point I have access to the objects that I want to use later, but none of the classes that I've seen at that point have an attribute collection, e.g.
objectThatWillBeAvailableAtWebSocket.addAttribute("some.custom.object", someObject);
By the time my code reaches an ServletRequestListener, ServerEndpointConfig.Configurator, or the registered Endpoint, I do not have any reference to the original servlet that added the Endpoint.
How can I pass an Object to the WebSocket servlet? I'm running my test code in Embedded Jetty, but I'm aiming for Container-agnostic code.

How to get the HTTP-Status from a webMethods com.wm.net.NetException?

How to get the HTTP-Status from a webMethods com.wm.net.NetException?
Is there a way to get the http status code from within the catch block of a java service after calling the pub.client:http service?
If you invoke the pub.client:http from within a flow service, you'll notice that it doesn't throw an exception. For example, a "403 Forbidden" error, will not throw an exception. Instead, it will output to the pipeline a header document.
Within the header document you will find the http status:
When you invoke pub.client:http from within a java service then the invocation is suppose to return an IData object. From that object you should be able to extract the status field using IDataUtil.
So, when you evaluate that the status is not OK, you can throw a ServiceException which will be caught by the flow try/catch.
Hope this helps!

Web Service Error path property must set before calling the send method

path property must set before calling the send method
What is the cause of this error?
Thanks
The usually means that the WSDL that you are using doesn't have a Service section defined to say where the web service is located. So the error is basically telling you that it doesn't know where to send the method call because there is no destination defined.
When you create an instance of the serivce try setting the Url property to the location of the service and then try calling the method again.

HTTP Error 500.0 - Internal Server Error in Secure WCF Service

Getting following error after hosting WCF Service in IIS.
HTTP Error 500.0 - Internal Server Error. The page cannot be displayed
because an internal server error has occurred.
Module IsapiModule
Notification ExecuteRequestHandler
Handler svc-ISAPI-4.0_32bit
Error Code 0x00000000
It is HTTPS having a secure certificate WCF Service.
Please help me to solve this problem.
It can be caused by many different things. You should try the following solutions:
1 First way
Right click the folder where your site is located: "C:\Users\NAME\SiteName" and select Properties.
Select the Security tab and click on Edit.
Add.. and type in "IIS_IUSRS".
2 Second way
By default, WCF Service OperationContracts can only be invoked using an HTTP POST. When you call open() on the Titanium HTTPClient, are you specifying a GET or POST for HTTP method parameter?
Secondly, since your service binding is using SOAP 1.1, you need to pass a SOAPAction header in your request so that WCF can route the message to the GetData method. If an Action parameter is not specified in the service's OperationContract attribute, the Action should be the method name preceded by the namespace and service contract name (probably http://tempuri.org/IService1/GetData if you're using what the default WCF application created). You'll also need to specify a content-type. So, you'd need to setup your xhr like this prior to calling send:
xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-16');
xhr.setRequestHeader('SOAPAction',
'"http://tempuri.org/IService1/GetData"'); xhr.send(s); Also, you can
explicitly specify an action for a WCF service operation:
[OperationContract(Action = "MyAction")] string GetData() {
// ...snip... }
xhr.setRequestHeader('SOAPAction', '"MyAction"');
And lastly, you can allow service operations to be invoked via an HTTP GET by decorating the method with the [WebGet] attribute. This allows the operation to be called in REST fashion: http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webgetattribute.aspx

Access wrapped request web method from web service in asp.net

I have a web service method taking multiple parameters.
Therefor the BodyStyle = WebMessageBodyStyle.Wrapped is set.
I want to access this method from a web service client therefor I did add the url of the service method to Reference->Add Services and I get the following error.
"There was an error downloading 'http://localhost:8080/Api/StoreI'.
The request failed with HTTP status 405: Method Not Allowed.
Metadata contains a reference that cannot be resolved: 'http://localhost:8080/Api/StoreI'.
The content type application/json of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
The first 323 bytes of the response were: '{"ErrorCode":110,"ErrorDetails":null,"Message":"The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.
This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details."}'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again."
What should I do in order to resolve this error?
What are the steps to access a secure web service from a client?
I an new to web services.
A reply would be highly appreciated.
Thanks.
I am not expert but change
BodyStyle = WebMessageBodyStyle.Wrapped
to
BodyStyle = WebMessageBodyStyle.Bare
The usage of the wrapped on the operation description does not add a layer of security on the message body. It simply wraps the request (or the response) in an XML element

Resources