Tag Archives: webMethods

Add custom solution to IS Admin page

Since I do not do this often I will put the description of how here

1. Create a flow service called “callback” in your package (or actually anywhere the IS can run it)
This flow service should contain at least one MAP with the following values:

name - description of menu item. Example: MYKPI
text - name of menu item. Example MYKPI 
url - URL to dsp page. Example: ../MYPackage
target - name of start page. Example: index.dsp

2. Create a flow service called “addSolution”
This service should contain one service from the WmRoot package: wm.server.ui:addSolution with the input: path to your “callback” service

3. Create a flow service called “removeSolution”
This service should also contain one service from the WmRoot package: wm.server.ui:removeSolution with the input: path to your “callback” service

4. Lastly we need to make sure that the solution is added to the IS Admin page every time the package gets reloaded
In your manifest.v3 file at the root of your package (example: MYPACKAGE/manifest.v3) there is a line like this:

<null name="startup_services"/>

This needs to be changed to:


    <null name="MYPACKAGE.processing:addSolution"/>
 

5. Run the “addSolution” service once
The link to your solution should now be visible in the IS Admin (after a refresh)

6. Done

Tested on webMethods 9.9 on Red Hat Linux 7.5

webMethods 8.2 How to POST a file to a HTML form

This was a lot harder than I first thought and the only way I was able to do it was by making the MIME document by hand. I first tried using the pub.mime:createMimeData function together with pub.mime:addBodyPart and finally creating the document using pub.mime:getEnvelopeStream and sending it with pub.client:http, but my HTML test form never recognized the data it received. After a lot of searching Google and the WmUsers forum I found a solution and I’m going to share that solution here.

My test HTML form:

<form method="post" enctype="multipart/form-data" action="index.php">

File:<input name="File" id="File" type="file" /><br />

User:<input name="UserID" id="UserID" type="text" value=""/><br />

Password:<input name="Password" id="Password" type="password" value="" /><br />

<input type="submit" value="Send">

</form>

The function of the form is that it will accept a file for upload if the user credentials are correct

The index.php file looks like this:

file_put_contents("recievefile.log", date(DATE_RFC2822) . "\n" . print_r($_FILES, true), FILE_APPEND);
file_put_contents("recievefile.log", date(DATE_RFC2822) . "\n" . print_r($_POST, true), FILE_APPEND);

This is just for debugging. The php file writes the contents of the global FILE and POST variables to a logfile where I can see the result. In a production environment you would point the form data to a regular input script (php, .NET ASP, JAVA and whatnot)

So how do we POST to this form from webMethods? The solution is to manually creating the MIME document. So here is what I did to fill the form variables from webMethods:
My MIME document (a simple string in webMethods):

----=Part--123456789
Content-Disposition: form-data; name="File"; filename="filename.xml"; 
Content-Type: text/xml 

%variableWithTheXMLString% 

----=Part--123456789
Content-Disposition: form-data; name="UserID";
Content-Type: text/plain

%variableWithTheUserID%

----=Part--123456789
Content-Disposition: form-data; name="Password";
Content-Type: text/plain

%variableWithThePassword%

----=Part--123456789--

Lets go through the different lines. The “—-=Part–123456789” line is a part separator. It can be almost anything as long as it starts with “- -“. A part is simply one variable definition to send to the form. We have three form variables to fill so we have three part sections.
The “Content-Disposition” maps the section to the form variable. First we say that it is form-data we are sending (same as form is declaring in enctype). The name key value pair maps agains the forms key value pairs (File to the first input, UserID to the second and so on..)
The “Content-Type” simply says what type of data we are sending. For a simple UserID variable text/plain is sufficient. For the xml file I’m using the text/xml content type.
In the “variableWithThe?” section we simply paste the content for the form variables (File, UserID and Password). This is pasted as plaintext string in my case since I do not use any binary data (images, zip files and so on).

Now, to get the pub.client:http service to correctly send this to the form we need to do one more thing. The default header for pub.client:http needs to be corrected so we set one header row to the following:
Key: content-type
Value: multipart/form-data;boundary=”–=Part–123456789″
The “method” variable is set to “POST” and the “url” to the url of the form

After this you should be ready to send xml files to the HTML form and it should recognize the data as a file (called “File”) and two post variables (“UserID” and “Password”)

Tested on webMethods 8.2.2, Apache 2.2.24 (Unix), PHP 5.3.26

webMethods 8.2 Unable to sync Document Type with correct broker Document Type

I stumbled across this problem after removing a Document Type in Designer without removing the corresponding Document Type on the Broker and then creating a new Document Type with the same name as the previous one. In this case the Broker will create a new Document Type with the extension “_1” and all changes will sync to this one instead.

Example:

  1. Delete a Publishable Document Type eg ‘myDocument’ using the Designer (without removing it from Broker)
  2. Now create a new Document Type called ‘myDocument’ and make it publishable
  3. If you now check the Broker Doc Type in the properties you will see that its name is wm::is::myDocument_1

To fix this we have to go through a number of steps:

  1. Open MWS->Messaging->Client Groups and click ‘IntegrationServer
  2. Open tab canPublish and use next to find ‘myDocument‘ and ‘myDocument_1
  3. Tick the box to the left of both Document Types and then click ‘Delete
  4. Open canSubscribe tab and use next to find ‘myDocument‘ and ‘myDocument_1
  5. Tick the box to the left of both Document Types and then click ‘Delete
  6. Now go to MWS->Messaging->Message Types
  7. Use ‘Next‘ to find both the ‘myDocument‘ and ‘myDocument_1
  8. Tick the box to the left of both Document Types and then click ‘Delete
  9. Now go into Designer and find the ‘myDocument‘ Document Type and lock it for edit
  10. In the properties section temporarily change ‘Publishable‘ to ‘false‘ and save
  11. Now change the ‘Publishable‘ property back to ‘true‘ and save

The doctype should now be called ‘myDocument‘ on the Broker and it should also be found in canPublish and canSubscribe on the ‘IntegrationServerClient Group. It is quite a lot of steps to fix this error. To never have to face this situation again be sure to ALWAYS delete the publishable document on the Broker if you remove it in Designer

NOTE! When this happens there is also a possibility that you have to reset the triggers that use this Document type – that has happened to me a few times. Just delete the Document Typer on the trigger and add it back (and set the appropriate filters again) and it should start working again

Tested on webMethods IS 8.2.2