"Add Service Reference..." for OData feed... not working in Visual Studio - visual-studio-2013

Why can't I "Add Service Reference" in Visual Studio to this odata endpoint:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx" Version="3.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="3.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="nsuli_com">
<EntityType Name="EntityType0">
<Key>
<PropertyRef Name="DateS"/>
</Key>
<Property Name="DateS" Type="Edm.DateTime" Nullable="false"/>
</EntityType>
<EntityContainer Name="us">
<EntitySet Name="ImportedSeries_NFPDates" EntityType="nsuli_com.EntityType0"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
It works from LINQPad 4 using the driver "WCF Data Services 5.5 (OData 3)"... but "Add Service Reference..." shows the error:
There was an error downloading 'http://nsuli.com/odata/us/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://nsuli.com/odata/us/'.
The content type application/xml;charset=utf-8 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 354 bytes of the response were: '<?xml version="1.0" encoding="utf-8"?><service xml:base="http://nsuli.com/odata/us/" xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"><workspace><atom:title type="text">Default</atom:title><collection href="ImportedSeries_NFPDates"><atom:title type="text">ImportedSeries_NFPDates</atom:title></collection></workspace></service>'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

It should be a metadata format issue. the following service can be used to "Add Service Reference". If you can change the service side code, you can use it as demo.
http://services.odata.org/V3/OData/OData.svc/$metadata
On the other hand, OData can use T4 to generate client code now. You can refer following blog:
http://blogs.msdn.com/b/odatateam/archive/2014/03/11/how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class.aspx

If I do
metadata = metadata.Replace(
"xmlns:edmx=\"schemas.microsoft.com/ado/2009/11/edmx\"",
"xmlns:edmx=\"schemas.microsoft.com/ado/2007/06/edmx\""
)
in my $metadata document, then "Add Service Reference" works just fine...........

Related

Unknown mediator referenced by configuration element: dataServiceCall

Hi I am trying to use Data Service Call. When I use it in any proxy service in wso2 I get an error Unknown mediator referenced by configuration element: dataServiceCall
https://apim.docs.wso2.com/en/latest/reference/mediators/dss-mediator/
I am following the link as mentioned above. Can someone guide me what am I doing wrong ?
Below is the code I have written
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestData" startOnLoad="true" transports="http https local" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<dataServiceCall serviceName="Hello">
</dataServiceCall>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
Probably this has to do with the version of the Integration Studio you are using. It seems the IDE is unable to find the DataServiceCall Mediator. First, try updating the Integration Studio referring this document. If that doesn't work, try using a newer version of the Integration Studio.
Once updated the Dataservicecall Mediator should be listed under the Mediators section.
You are calling a dataservice but you didn't initiate this dataservice project before,so you have to make a dataservice before calling this dataservice from the proxy service.After that a design of "dataServiceCall " will appear in the integration Studio.

getting error Failed to execute 'fetch' on 'Window': Invalid name

I am trying to publish API in wso2 API Manager. But I am using basic security with my authorization key. I am getting a type error: Failed to execute 'fetch' on 'Window': Invalid name. I tried to change the swagger file. But didn't get the required response.
If you are trying to send a header to your backend through APIM, you have define it as a header under resources in the Publisher portal.
However, if the name of your header is Authorization you will have to use some sort of a mediation to send this to your backend. For example,
<sequence xmlns="http://ws.apache.org/ns/synapse" name="KeyExchange">
<property name="Custom" expression="get-property('transport', 'Custom')"/>
<property name="Authorization" expression="get-property('Custom')" scope="transport"/>
<property name="Custom" scope="transport" action="remove"/>
</sequence>
If you add the above to your in-sequences, you will have to send a header called Custom with the key you need to send to the backend. Then APIM will replace this Custom header with Authorization header when sending the request out from APIM.
If you have enabled Basic auth for your API created in APIM, you need to follow [1] to invoke the API.

Cannot show the endpoint list when calling link without ?wsdl, but still can call the SOAP web service?

I have a web service with Spring and CXF like:
#Service
#WebService(serviceName = "ReceiveMultiFromVOfficeImpl")
#RequiredArgsConstructor
public class ReceiveMultiFromVOfficeImpl {
public Long returnSignReult(ResultObj resultObj) {
log.info("Start receive from Voffice...");
return 0L;
}
}
and my ws-endpoint-lazy-load.xml file config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans">
<bean class="com.abc.fw.ws.CxfWsEndpointFactory">
<property name="endpoints">
<list>
<value>com.abc.bccs2.service.TestCustomService</value>
<value>com.abc.voffice.vo.ReceiveMultiFromVOfficeImpl</value>
</list>
</property>
</bean>
</beans>
When I call http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl, it works and I can call SOAP. But when I call http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl, I expected it will show the endpoint's information. It shows error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Fault occurred while processing.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What I want is something like:
How do I fix that?
I'm not sure you understand how a SOAP web service works, so here is some explanation about what you are seeing when accessing those URLs.
When dealing with a SOAP web service there is only one endpoint address to use to send messages to the web service and it is invoked over POST.
In your case:
POST http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl
is how you invoke the web service. As long as the web service is running and listening on that address, then a POST with a SOAP message will invoke the web service.
Because a SOAP web service can be described by a WSDL document, there must be some way to obtain the WSDL for the web service. By convention, it is accessible over a GET request at the web service endpoint by specifying a ?wsdl parameter.
In your case:
GET http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl
will return the WSDL of the web service.
Any other GET/POST/URL comination will either return an error or will return some other information provided for convenience, assuming the web service framework used to build the web service does that. For example, this web service (http://www.dneonline.com/calculator.asmx) allows you to call its endpoint over GET and will return a human readable summary of what the WSDL accessible at (http://www.dneonline.com/calculator.asmx?wsdl) contains, but don't expect that to be the case with every framework out there (from what I remember CXF just returns an error if you call the web service endpoint over GET without a ?wsdl parameter).
So, to recap, the HTTP verbs and URLs valid for your web service are:
POST http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl -> to invoke the service
GET http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl -> to obtain the service WSDL
Some other resources to read:
How is a SOAP call possible without WSDL?
The WSDL is not the SOAP web service
Is it mandatory to have a WSDL definition accessible using ?wsdl?
Finally, if you are using the proper URL and HTTP verb combination and you are getting that error, note that Fault occurred while processing is a generic error message that may show some issue with the web service code. Maybe there is a NullPointerException or some other error in your web service code. You need to look in your web service logs or in your web service console to see if there are any other exception messages or stacktrace that points to a root cause for that fault message.

Why do I get "Type could not be found" WCF error on IIS server but not locally with Visual Studio 2010? [duplicate]

This question already has answers here:
The type 'RestService.weddingservice', provided as the Service attribute value in the ServiceHost directive could not be found
(6 answers)
Closed 7 years ago.
The error is:
The type 'WF.XXX.WebServices.XXXXService', provided as the Service
attribute value in the ServiceHost directive, or provided in the
configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.
Stack Trace:
[InvalidOperationException: The type 'WF.XXX.WebServices.XXXXService',
provided as the Service attribute value in the ServiceHost directive,
or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[] baseAddresses) +52742
System.ServiceModel.HostingManager.CreateService(String
normalizedVirtualPath) +1459
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +623
[ServiceActivationException: The service
'/XXXXX/XXXXXService/XXXXService.svc' cannot be activated due to an
exception during compilation. The exception message is: The type
'WF.XXX.WebServices.XXXXService', provided as the Service attribute
value in the ServiceHost directive, or provided in the configuration
element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found..] System.Runtime.AsyncResult.End(IAsyncResult result)
+687598 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +190
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult
ar) +304662
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult
ar) +94
How to fix this error on the server?
Update on 9/18/2012:
I have Visual Studio 2012 and .NET Framework 4.5 installed on my machine but server has only .NET Framework 4.0. I am not sure if this matters, because I built the service with .NET Framework 4.0.
But strangely, I noticed a 4.5 feature when I run my project. It shows a URL to singleWSDL file, which is not available in .NET 4.0 version. Why does this show up when the project is built with .NET Framework 4.0? Here is the screenshot:
Update 9/19/12:
Here is the relavant web.config file:
<system.serviceModel>
<services>
<service name="XXXXService">
<!-- Use a bindingNamespace to eliminate tempuri.org -->
<endpoint address="" name="XXXXService"
binding ="basicHttpBinding"
bindingNamespace="#services.url#/XXXXService"
contract="WF.XXX.WebServices.XXXXService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
To answer your questions
(1) Make sure you have built your project and the the dll which contains the service type XXXXService is placed in the bin directory.
(2) Single Wsdl is a new 4.5 feature. Since 4.5 is an in-place upgrade of 4.0 you will get the benefit of ?SingleWsdl even if you target your project to 4.0. But when you deploy the same service on a machine with just 4.0 then you will not be able to get this. To get this on your service machine make sure you have 4.5 on that too.
Hope this helps.
Thanks!
I had the same problem and the cause was that I had changed the namespace in the code files IService1.cs and Service1.svc.cs but forgot to change the namespace in the Service1.svc file.
E.G. in service1.svc
< % # ServiceHost Service="WcfService2.Service1" % >
must be changed to:
< % # Service="NewNamespaceName.Service1" % >
You can build the solution without Visual Studio catching the typo error.
I had the same issue. In my case, simply deleting the bin and obj folders and rebuilding fixed the issue.

EF 4.3 config section

Hi I have the following in my web.config
<entityFramework>
<contexts>
<context type=" Dashboard.Domain.DataContext, Dashboard.Domain">
<databaseInitializer type="Dashboard.Domain.DataContextInitializer, Dashboard.Domain" />
</context>
</contexts>
the problem is that when I now try to scaffold via the gui tools in vs 2010 it throws a design time exception
Unable to retrieve meta data for 'entity type' Failed to set database initlizer of type 'Init type goes here' specified in app config. see inner exception
why does this happen it also happened with the EF 4.1 way of defining the intializer in config.
Thanks

Resources