ArcGIS API for SIlverlight 3.1 SIlverlight 5: Esri identify task - silverlight-5.0

RE: ArcGIS API for SIlverlight 3.1 SIlverlight 5: Need help with identify task
I have the following using statements:
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Printing;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Toolkit;
using ESRI.ArcGIS.Client.Toolkit.Primitives;
but I get an error in this line:
private List<DataItem> dataItems = null;
The type or namespace name 'DataItem' could not be found (are you missing a using directive or an assembly reference?
Please help.
Thanks

The DataItem class is just used to define your object to bind your data to the view. If you look at the code for the identify sample in the interactive SDK the DataItem is defined at the bottom of the file
public class DataItem
{
public string Title { get; set; }
public IDictionary<string, object> Data { get; set; }
}

Related

ArrayOfXXX class out of soap input param of array type

I have a method with input param as Array. When I generate stub out of it creates List type.
But I want to know how to create a wrapper class around array type e.g. for class Apple it should create ArrayOfApple.
Is there any change needs to be done in class or any specific plugin need to be used?
Note: I am using JAXWS with Apache CXF implementation
Below is the sample code:
EmployeeService.java:
#WebService(endpointInterface="com.test.EmployeeService")
#SOAPBinding(style=Style.DOCUMENT)
public class EmployeeService {
public String updateEmpRoles(#WebParam(name="EmpRoles")EmpRole[] empRoles) {
return "SUCCESS";
}
}
EmpRole.java :
#XmlType(name="EmpRole")
public class EmpRole {
private String empRole;
public String getEmpRole() {
return empRole;
}
public void setEmpRole(String empRole) {
this.empRole = empRole;
}
}
After publishing, wsdl is getting generated as below -
But what I expect is WSDL should create ArrayOfEmpRole and it should wrap List<EmpRole>.
Kindly help
In short - I want something that Björn doesn't want in below link. (In his case, it's automatically creating ArrayOfXXX, this is what I need) - Arrays in SOAP method Parameters generated via JAX-WS?
I would switch from Code first to a Contract first approach which means start with the WSDL and generate a stub using wsdl2java from it. This way you can ensure that the WSDL looks like the way you want.
If you want to stick to the current approach, the easiest way to achieve a wrapper is probably to introduce another class.

Sitecore: Glass Mapper Code First

It is possible to automatically generate Sitecore templates just coding models? I'm using Sitecore 8.0 and I saw Glass Mapper Code First approach but I cant find more information about that.
Not sure why there isn't much info about it, but you can definitely model/code first!. I do it alot using the attribute configuration approach like so:
[SitecoreType(true, "{generated guid}")]
public class ExampleModel
{
[SitecoreField("{generated guid}", SitecoreFieldType.SingleLineText)]
public virtual string Title { get; set; }
}
Now how this works. The SitecoreType 'true' value for the first parameter indicates it may be used for codefirst. There is a GlassCodeFirstDataprovider which has an Initialize method, executed in Sitecore's Initialize pipeline. This method will collect all configurations marked for codefirst and create it in the sql dataprovider. The sections and fields are stored in memory. It also takes inheritance into account (base templates).
I think you first need to uncomment some code in the GlassMapperScCustom class you get when you install the project via Nuget. The PostLoad method contains the few lines that execute the Initialize method of each CodeFirstDataprovider.
var dbs = global::Sitecore.Configuration.Factory.GetDatabases();
foreach (var db in dbs)
{
var provider = db.GetDataProviders().FirstOrDefault(x => x is GlassDataProvider) as GlassDataProvider;
if (provider != null)
{
using (new SecurityDisabler())
{
provider.Initialise(db);
}
}
}
Furthermore I would advise to use code first on development only. You can create packages or serialize the templates as usual and deploy them to other environment so you dont need the dataprovider (and potential risks) there.
You can. But it's not going to be Glass related.
Code first is exactly what Sitecore.PathFinder is looking to achieve. There's not a lot of info publicly available on this yet however.
Get started here: https://github.com/JakobChristensen/Sitecore.Pathfinder

How do I get a Roslyn workspace from a VS package?

From a Visual Studio 2015 CTP5 package, how do I get the current Roslyn workspace?
I looked at
How to get reference to 'Roslyn' Workspace object from IVsSolution?
and
Roslyn: How to get a reference to Workspace from currently loaded solution?
but I still can't make it work:
Workspace.CurrentWorkspace does not exist anymore
I have tried importing the VisualStudioWorkspace but it is still null:
public sealed class VSPackage1Package : Package
{
....
[Import]
public VisualStudioWorkspace Workspace { get; set; }
....
protected override void Initialize()
{
// Workspace is null here...
Is there a sample somewhere?
I don't see any definition of VisualStudioWorkspace (or the Microsoft.VisualStudio.LanguageServices assembly)
It's there, double check you're looking in the right place.
[Import]s only work if the class you're working in itself is MEF exported. If it's not (like a Package in your case), just write:
var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
var workspace = componentModel.GetService<VisualStudioWorkspace>();

Generic WebService (SOAP) client library for C++

I'm looking for a simple C++ WebService Client Library that can be easily linked into my application.
Preferably this library:
can be used to access any SOAP WebService (so I can pass the URL, the WebService name, the WebService method and all the arguments as arguments to a function call)
can be linked statically in a C++ application (so no DLL's)
is freeware or available at a low cost
can be used royalty-free in my application
can query the Web service for its WSDL and return me the available method names, arguments of the methods and their data types
Before anyone of you answers .NET: been there, tried it. My major objections against .NET are:
you can generate the proxy but it's impossible to change the WebService name in the generated proxy code afterwards, since .NET uses reflection to check the WebService name (see Dynamically call SOAP service from own scripting language for my question regarding that problem)
generating the proxy class on the fly doesn't always seem to work correctly
I already used Google to look up this information, but I couldn't find one.
Thanks
EDIT:
To clarify this further, I really want something where I can write code like this (or something in this style):
SoapClient mySoapClient;
mySoapClient.setURL("http://someserver/somewebservice");
mySoapClient.setMethod("DoSomething");
mySoapClient.setParameter(1,"Hello");
mySoapClient.setParameter(2,12345);
mySoapClient.sendRequest();
string result;
mySoapClient.getResult(result);
No dynamic code generation.
Have you looked at gSOAP? I think it will be suitable for your needs.
http://gsoap2.sourceforge.net/
I found a solution using on-the-fly-generated assemblies (which I couldn't get working the previous time). Starting point is http://refact.blogspot.com/2007_05_01_archive.html.
E.g. This is the code to use the PeriodicTable web service:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Web;
using System.Web.Services;
using System.Web.Services.Description;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Xml.Serialization;
using System.IO;
using System.Reflection;
namespace GenericSoapClient
{
class Program
{
static void method1()
{
Uri uri = new Uri("http://www.webservicex.net/periodictable.asmx?WSDL");
WebRequest webRequest = WebRequest.Create(uri);
System.IO.Stream requestStream = webRequest.GetResponse().GetResponseStream();
// Get a WSDL
ServiceDescription sd = ServiceDescription.Read(requestStream);
string sdName = sd.Services[0].Name;
// Initialize a service description servImport
ServiceDescriptionImporter servImport = new ServiceDescriptionImporter();
servImport.AddServiceDescription(sd, String.Empty, String.Empty);
servImport.ProtocolName = "Soap";
servImport.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;
CodeNamespace nameSpace = new CodeNamespace();
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
codeCompileUnit.Namespaces.Add(nameSpace);
// Set Warnings
ServiceDescriptionImportWarnings warnings = servImport.Import(nameSpace, codeCompileUnit);
if (warnings == 0)
{
StringWriter stringWriter =
new StringWriter(System.Globalization.CultureInfo.CurrentCulture);
Microsoft.CSharp.CSharpCodeProvider prov =
new Microsoft.CSharp.CSharpCodeProvider();
prov.GenerateCodeFromNamespace(nameSpace,
stringWriter,
new CodeGeneratorOptions());
string[] assemblyReferences =
new string[2] { "System.Web.Services.dll", "System.Xml.dll" };
CompilerParameters param = new CompilerParameters(assemblyReferences);
param.GenerateExecutable = false;
param.GenerateInMemory = true;
param.TreatWarningsAsErrors = false;
param.WarningLevel = 4;
CompilerResults results = new CompilerResults(new TempFileCollection());
results = prov.CompileAssemblyFromDom(param, codeCompileUnit);
Assembly assembly = results.CompiledAssembly;
Type service = assembly.GetType(sdName);
//MethodInfo[] methodInfo = service.GetMethods();
List<string> methods = new List<string>();
// only find methods of this object type (the one we generated)
// we don't want inherited members (this type inherited from SoapHttpClientProtocol)
foreach (MethodInfo minfo in service.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly))
{
methods.Add(minfo.Name);
Console.WriteLine (minfo.Name + " returns " + minfo.ReturnType.ToString());
ParameterInfo[] parameters = minfo.GetParameters();
foreach (ParameterInfo pinfo in parameters)
{
Console.WriteLine(" " + pinfo.Name + " " + pinfo.ParameterType.ToString());
}
}
// Create instance of created web service client proxy
object obj = assembly.CreateInstance(sdName);
Type type = obj.GetType();
object[] args0 = new object[] { };
string result0 = (string)type.InvokeMember(methods[0], BindingFlags.InvokeMethod, null, obj, args0);
Console.WriteLine(result0);
object[] args1 = new object[] { "Oxygen" };
string result1 = (string)type.InvokeMember(methods[1], BindingFlags.InvokeMethod, null, obj, args1);
Console.WriteLine(result1);
}
}
}
}
In this code I explicitly use methods[0] and methods[1] but in reality you would check the method names of course. In this example I get the names of all elements in the periodic table, then get the atomic weight of oxygen.
This example does not yet contain logic to support a proxy. I still need to add this, but for the moment, it solves my biggest problem, namely, having a generic SOAP client.
EDIT:
I know this code is C# and I was originally asking for a C++ solution, but this code proves that it can work in a .NET environment (which I can still use in limited parts of my application), and I will probably rewrite this code into C++/.NET, which solves my problem.
Axis2C : http://axis.apache.org/axis2/c/core/index.html
Axis2C ticks most of the above , please check for static linking. .
EDIT: As per last few messages on the list, static linking is incomplete. The below still holds:
Perhaps I do not understand the question correctly. Any web service you call you need to specify the endpoint URL and the operation & parameters.
Are you referring to dynamically "discovering" the services & presenting the option to call them...? If so I doubt this is possible.
If you are referring to generic framework, SOAP messages are client end responsibility any way... You should not have a problem wrapping them under some of the toolkit API's. WSDL code generation is not mandatory. I have written a few services from scratch, i.e. You can set endpoint, service and craft the SOAP message, parameters, headers etc. as you feel.
Cheers!

the type or namespace name 'webmethod' could not be found

I'm using jquery, ajax, & .net to call a method. I see lots of examples on the net saying to put [Webmethod] above the method but I'm keeping getting the error the type or namespace name 'webmethod' could not be found. I have put "using System.Web.Services;" at the top. What else needs to be done?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
[WebMethod]
public static string GetDate()
{
return DateTime.Now.ToString();
}
}
Add a reference to System.Web.Services.dll in your project.
It is most likely missing for you to be getting this error because you already have the correct using statement
Add the following on top of the page:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
Simple answer to this question is to just Add reference of system.web.services from .net framework folder.
Example:
Consider I have a project which is already referenced system.web.services
Now If I right click on System.web.services
You can see that this assembly is inside .Net Path so you can easily add reference of this assembly in your project from there.
Solution
Just right click on references ,select add reference click browser button of selection manager window go to path and add references like this.