How to generate non-secure stubs in Axis2 using wsdl2java - axis2

I am attempting to learn Axis2 Web Services, and am working through a tutorial on RoseIndia web site (link text). In the example for the client, it generates the stubs using wsdl2java, and it generates the stubs which use http://localhost:8080, however, when I do it, it creates the stubs to use the secure links https://localhost:8443. I have not installed SSL onto my local dev app server (Tomcat).
I have checked the wsdl2java documentation and can't find any reference to security settings. How would I make these stubs use the basic http://localhost:8080 references

Look at your WSDL file. In Axis2 1.5 the wsdl2java tool will use this SOAP1.2 port to generate the target endpoint for your stub:
<wsdl:port name="HelloWorldServiceHttpSoap12Endpoint" binding="ns:HelloWorldServiceSoap12Binding">
<soap12:address location="http://localhost:8082/axis2/services/HelloWorldService.HelloWorldServiceHttpSoap12Endpoint/" />
</wsdl:port>
You can use the -pn option of wsdl2java if you need to use another port.
Download your WSDL locally and verify that the port section is correct (no https). Further generate the sources with wsdl2java, e.g. on my machine:
lucho#lucholinuxpc:~/axis2-1.5.1/bin> ./wsdl2java.sh -uri /home/lucho/sayhello.wsdl
Using AXIS2_HOME: /home/lucho/axis2-1.5.1
Using JAVA_HOME: /opt/jdk1.6.0_18
Using JAVA_OPTS: -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Retrieving document at '/home/lucho/sayhello.wsdl'.
Now check your generated stub, you should see something like this in case your WSDL looks like mine:
/**
* Default Constructor
*/
public HelloWorldServiceStub() throws org.apache.axis2.AxisFault {
this("http://localhost:8082/axis2/services/HelloWorldService.HelloWorldServiceHttpSoap12Endpoint/" );
}
Next, in your test code you may alternatively use a constructor for your stub that takes the target endpoint. Actually I prefer this approach because the WS client is more flexible to changes in the target network. For your question should be something like:
public HelloWorldServiceStub(java.lang.String targetEndpoint)
And last but not least I recommend you this book for quick start-up tutorial SOAP Attachments using apache axis2
Cheerz!

Related

Mule Web Service Consumer not loading WSDL

I am trying to load WSDL using mule's Web Service Consumer but no success. If I try same WSDL from SOAPUI it works without running into any issues.
I tried below 2 options and both directing me to different issues. Any suggestion?
Option#1. Tried to load WSDL with URL gives me PKIX path building failed as below
Option#2. Also, tried to load WSDL as resource i.e. by saving it into src/main/resources folder. This gives me below
NOTE: I am using Anypoint Studio 6.4.4 with mule Community Edition 3.9 and JDK 1.8.
WSDL: https://esweb.revenue.louisiana.gov/fsettest/fsetgatewaywebservice.asmx?wsdl
you need to add the wsdl certificate to Java cacerts keystore. Here you have a useful link:
https://knowledge.digicert.com/solution/SO4085.html
On the other hand, you are getting the second error, because that wsdl you downloaded has an import of another wsdl (this is the other wsdl http://esweb.revenue.louisiana.gov/fsettest/fsetgatewaywebservice.asmx?wsdl=wsdl1).
If you want to do it this way (that I would not recommend), you will need to download all the wsdls that are imported, and reference them locally.

Using ChannelFactory with WorkflowServiceHost

Is there a way to do the service inference on a workflow definition XAML to create an interface that can be distributed to the client to be used with ChannelFactory instead of the host exposing WSDL and the client having to generate a service definition by adding a service reference?
I did this in a three step process:
Temporarily exposing the metadata from the workflow service
Creating proxy code with svcutil
Changing configuration back to not exposing metadata
In detail:
Include your XAMLX file which defines the service in a project that was created as "WCF Workflow Service Application" (DeclarativeServiceLibrary1)
Compile the project
Set the project as startup project
Select xamlx file in Solution Explorer
Press Ctrl-F5 -> WCF Test Client starts, you see your service loaded
RightClick on the xamlx URL in WCF Test Client, choose Copy address (e.g. http://localhost:56326/Service1.xamlx)
Open a VS2010 Admin console window
Create the proxy code with svcutil.exe:
cd /D %TEMP%
svcutil http://localhost:56326/Service1.xamlx
This creates two files, a *.cs and a *.config, that contain the proxy code
I had a lot of problems with other ways of craeting the proxy code (inside VS2010), the external svcutil was the most stable way to do it. Hope this helps.

wsdl2java doesn't produce any output

I'm fairly new to web services and I've successfully created a web service using axis2 and tomcat 7. Now I'm trying to create a client for the web service using wsdl2java. I'm working on Windows so the command I've been trying is this:
C:\axis2-1.5.4\bin> wsdl2java -uri http://localhost:8080/axis2/services/MyService
I've set the AXIS2_HOME, JAVA_HOME, CLASSPATH like this:
AXIS2_HOME -> C:\axis2-1.5.4
JAVA_HOME -> C:\Program Files\Java\jdk1.7.0
set CLASSPATH=C:\axis2-1.5.4\lib\axis.jar;C:\axis2-1.5.4\lib\axis-ant.jar;C:\axis2-1.5.4\lib\commons-discovery-0.2.jar;C:\axis2-1.5.4\lib\commons-logging-1.0.4.jar;C:\axis2-1.5.4\lib\jaxrpc.jar;C:\axis2-1.5.4\lib\log4j-1.2.8.jar;C:\axis2-1.5.4\lib\saaj.jar;C:\axis2-1.5.4\lib\wsdl4j-1.5.1.jar;C:\axis2-1.5.4\lib\activation.jar;C:\axis2-1.5.4\lib\mailapi.jar
My problem is that this: C:\axis2-1.5.4\bin> wsdl2java -uri http://localhost:8080/axis2/services/MyService doesn't produce any output at all in the console and doesn't create the stub class. I've no idea what I'm doing wrong here. I've tried other wsdl files as well and same thing happens. I would really appreciate any suggestions.
Thanks!
Try adding "?wsdl" to the end of the URI: http://localhost:8080/axis2/services/MyService?wsdl. That's the correct form for a URL that returns the WSDL.
Aside from that, the wsdl2java reference says that -uri should name a file on the local filesystem. It may be that HTTP URLs aren't supported.
wsdl2java tools supports http url. But I also think that the problem here is that you URL does not point to the wsdl file (which should be ?wsd)

.net-WCF How do we create a client programatically?

How do I create a client programatically?
Open Visual Studio command prompt and move to client application folder using change directory command and type
svcutil.exe http://your_service_url/your_service_name.svc?wsdl
This will generate a configuration file (output.config) and a client class.
Client class name will be your_service_nameClient
Next you need to copy the <system.serviceModel> section from output.config to your App/Web config. Now your client application is ready to consume the service.
You can create client class object and invoke service methods.
Hope this will help you
You'll need to start the svcutil.exe process -- it could be done from a program, but it will generate source code, not binary code.
If you are new to WCF check out this site:
http://msdn.microsoft.com/en-us/netframework/dd939784.aspx
If you are only interested in learning how to create a client, this is the video for you:
http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Client/

Silverlight Business Application template with WCF is throwing warning

I am using the Silvelight Business Application template. I wrote a function which uses Membership.getUserList function to return the user list. I tried exposing it as Service using WCF. But when I try to compile the client side code it throws a warning saying "Client Proxy Generation for user_authentication.Web.Service1 failed'. Why does it happen?
The complete warning message is:
Warning 4 Client proxy generation for
service
'user_authentication.Web.Service1'
failed: Generating metadata files...
Warning: Unable to load a service with
configName
'user_authentication.Web.Service1'. To
export a service provide both the
assembly containing the service type
and an executable with configuration
for this service.
Details:Either none of the assemblies passed were executables
with configuration files or none of
the configuration files contained
services with the config name
'user_authentication.Web.Service1'.
Warning: No metadata files were
generated. No service contracts were
exported. To export a service, use
the /serviceName option. To export
data contracts, specify the
/dataContractOnly option. This can
sometimes occur in certain security
contexts, such as when the assembly is
loaded over a UNC network file share.
If this is the case, try copying the
assembly into a trusted environment
and running it.
Hard to say, I'm not a good enough clairvoyant yet ;-) ... Is your webservice actually already compiled, published and running? Maybe here you can find further hints:
MSDN WCF Forums: svcutil Error