I have a WCF web service using wsHttpBinding that I am consuming from a Java client. I generated code from the WSDL using wsimport. The java client appears to be creating the service fine but when I call a method on the service the client just spins.
MyService s = new MyService();
IMyService i = s.getWSHttpBindingIMyService();
returnedValue = i.getSomething(2); // method call
Can a java client communicate with a WCF webservice that is using wsHttpBinding? And what is the best way of doing so?
Any help will be appreciated.
You'll definitely want to use WSIT to help write your client, and it's probably easiest to use the whole Metro stack. Metro contains jaxws-ri, WSIT & JAB in its jars (webservices-rt.jar & webservices-api.jar).
A few steps to get you started:
Does the published WSDL of the WCF service contain a WS-Policy section? If not, get that info & place it into your local local copy of the the service WSDL file. Re-run wsimport on the WSDL containing the WS-Policy section.
Include the metro jars on your client's classpath.
Write a file named wsit-client.xml file & place it into WEB-INF/classes (or on your classpath). Here's a sample. Now, when you use the client, you should see an INFO message in your console that says: WSP5018: Loaded WSIT configuration from file:
If you get stuck on WS-Policy or wsit-client.xml, use Netbeans. I use Eclipse for development, and while I don't really like Netbeans, I've used it as a reference a number of times, because it has configuration settings in the IDE that will enable you to secure web services & write a web service client that needs security, and it'll generate wsit-client.xml & WSDLs with WS-Policy info in them for you. Try writing a web application in Netbeans & pointing to the service's WSDL to generate a web service client there & see what the resulting files look like.
You can get some questions answered here on SO, but the java.net Metro forum is also pretty active, and you can get good support there as well. Just be prepared for answers like "do XYZ in Netbeans/Glassfish".
Probably this would help: WCF service & Java client
Related
We are consuming a WCF service using coldfusion. the wcf service does not expose metadata endpoint instead they share service contracts in dll and svcutil.exe generated proxy class.
Now, how can i consume the wcf service in coldfusion without generating proxy.? i see .net client can access that way by creating channel factory as given in the following url:
http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/accessing-wcf-service-without-creating-proxy/
i researched adobe help page:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78b4.html
but there is no clue.
what possibilities i have to consume the service?
I don't understand the question. Let me see if I can figure this out:
No proxy would be involved unless you specify one. The client computer will invoke and consume the web service on the server without anything inbetween. It's a standard HTTP call.
You say you are connecting to svcutil.exe, a c# utility. So you seem to mean you have an additional layer between the two CF applications, correct? So svcutil.exe is acting as the "proxy"?
I have been given a "working" SoapUi 4.0.1 project that accesses an existing 3rd party service. The project has two xml requests that I can run to see, in SoapUi , a "found" and a "not found" response.
Along with the project is a wsdl file a couple of certificate files (for message security) and a bunch of xml schemas.
I've been told to implement a c# client that uses the service based on the "documentation" provided by the above.
I'm not experienced in the intricacies of WCF configuration nor SoapUi. There, at least, there seems to be a mismatch between the terminology SoapUi uses and that I see in the WCF configuration tool.
I'm looking for advice, hints, pointers on duplicating the SoapUi calls in my .NET code, perhaps a terminology mapping between the two tools would be a good start.
First you need to create a service proxy using the right-click "Add Service Reference" in Visual Studio or by running the SVCUTIL.EXE tool from a VS command-line. This will provide you with both a basic configuration file as well as a client implementation. All you need to do this is the actual metadata files (WSDL+XSD) or a URL to a hosted version of it.
It is not clear weather the SoapUI project you have makes client requests to the actual service or if it uses the built-in MockService feature where SoapUI hosts a 'fake' service instance. Either way the MockService feature can be your best friend doing WCF development.
If you are using the SoapUI MockService feature and do not have the original WSDL or access to it you can then use the metadata exposed by the MockService. One way of finding the link to the WSDL is by clicking the link button:
Copy the URL you get from there and generate the proxy from a Visual Studio command-prompt:
svcutil.exe http://localhost:8088/mockKramerServiceSoap?WSDL
SoapUI has one really great feature when trying to replicate SOAP calls in WCF. You can examine requests coming into the MockService from the .NET proxy and compare them with the calls made from SoapUI.
Hopefully this helped you getting started.
I have searched over internet but did not get any specific answer or i say a satisfied answer that how can we make DLL of a WCF Service which is having webHttpBinding in its web.Config file.
I have a WCF Service which i want to deploy on client's server but i dont want them to see my code as if i host this service on their server they will able to see my code and i don't want that.
This Service responses in JSON Format which can be access only through URL.
so how to create a dll of this service and then host this on Server.
1) A DLL does not have a web.config or any other .config.
2) Deploying a Service as a DLL does not prevent anyone from seeing the (disassembled) code.
3) You may be able to configure your service in code, but only when it's self-hosting. Which would usually be as an EXE, a DLL needs something else to host it.
I have created two wsdl files with shared types imported from xsd schema file.
After that I have created web services using interface generated by wsdl.exe tool with parameter /serverInterface.
Frist web service, have web method “RegisterData” with put into queue some complex object to be processed, by system “A”. As result of this method is returned Boolean (with tell us that object was registered successful).
Second web service, have web method “UpdateData” to update some data in system “B” based on this same object , with was changed in process on system “A”.
So in system “A” I have to create client for second web service, where I will call method “UpdateData” with this modified complex object us argument.
But when I’m creating this client in Visual Studio (by add web reference or add service reference) I have to create some namespace for client. And then when I’m trying to call “UpdateData” agument have different namespace for this same object received from first web service “RegisterData” method.
I would like to create first web service and second web service client , where I can use this same type object between them.
Thank you very much for help.
I don't believe this is possible with ASMX web services.
WCF does support this, however.
WCF Links:
WCF Developer Center
Beginner's Guide to Windows Communication Foundation
How to: Configure a Service to Reuse Existing Types
Actually, I think I may have misread your question. I though you were trying to share the same types between the client and the server. ASMX cannot do that. However, it appears you are trying to share the same types between two client proxies. You can do that easily using the WSDL.EXE tool.
Consider a schema, DataTypes.xsd, and two WSDL files that import it, ServiceA.wsdl and ServiceB.wsdl. To create the server interfaces, use:
wsdl /serverInterface /n:SharedTypes.Servers /out:Services.cs ServiceA.wsdl ServiceB.wsdl DataTypes.xsd
This will create interfaces which you can implement in order to create your services. These interfaces will both use one set of classes created from DataTypes.xsd. To create the proxy classes, simply use:
wsdl /n:SharedTypes.Proxies /out:Proxies.cs ServiceA.wsdl ServiceB.wsdl DataTypes.xsd
Notice that you do not need the /sharedTypes switch. That has a different purpose. It is for combining types of external services when you need to download the WSDL and any XSD from the service.
I have tried this using an example like yours, ServiceA posting a message into a queue, and a client picking up that message and sending it to ServiceB. It works quite well.
I agree that it is not possible to do this via the VS Web Reference functionality. To meet your requirements you can use the wsdl.exe utility with the /sharetypes switch.
For more information see Web Services Description Language Tool (Wsdl.exe)
Could anyone give me a small and simple example of how to do this? Or some good pointers on how to get started.
I would like to create a C# client that can send a file or some text or xml or whatever, to a web service or something similar written in PHP, where the PHP Web Service stores it in a file or a database or something like that. Just not sure how to get started.
I guess the first step would be to create the php web service. And then it perhaps would be quite easy to use it in C#, since I could probably pretty much use the "Add Web Reference" button in vs and then go from there?
You can take a look at this tutorial showing how to develop a web service using php. The .NET client will be pretty straightforward as you mentioned.
I'm not versed in the C# aspect of your question, which you intend to be the consumer. But if you don't mind using a library to expedite the process of getting the webservice up and running, you can set one up very quickly using Zend Framework. Check out the documentation for setting up a Zend_Rest_Server.
Just a thought... if the service only has to support simple operations like "upload a file", perhaps avoid WSDL all together? I assume PHP can handle raw requests - so you can use the oh-so-complex .NET client:
using (WebClient client = new WebClient())
{
client.UploadFile("http://some/upload.php", "foo.bar");
client.UploadString("http://some/upload.php", "some text");
}
etc. Likewise, you can often easily use POX / REST without the complexity of a formal web-service contract. The above code just does a simple HTTP request with the file-contents/string in the body.
you are right. all you need to do is to create a simple web service in PHP, which accepts the request/xml/file and then stores it in a database. then you can use the webservice using any technology, C# for sure.
in order to write a web service in PHP, I think it is better to choose your webservice type in the first step. it can be a REST web service, or SOAP, or XML-RPC. it depends on the level of complexity of your application.
if your application is as simple as just throwing a string to the webservice or a file URL, so then the webservice can store that string, or fetch the file from the URL and stores it in database, I recomment REST. because it is simpler. as simple as just writing a simple PHP script that uses it's HTTP parameters as input.
but incase you want it to be more secure or have more complex needs, It is easy to have SOAP services in PHP. if you wanted to work with SOAP, PHP has an extension (php-soap) which you can install and use the built-in functionality of PHP-SOAP. if you are using an older version of PHP that does not support the extension, or your application will be hosted where php-soap is not installed, there is pure PHP implementaion of SOAP protocol, named nusoap. it is open source and works very well.
http://sourceforge.net/projects/nusoap/
I have made work in PHP NuSOAP webservice and my C# mobile client fetching data from web services.Below is the link
http://khanmubeen.wordpress.com/2010/11/18/web-services-with-php-nusoap-c-mobile-client/
In case you like to know more from me welcome to inbox me at mubeen44us at gmail.com